我一直在尝试在我的开发环境中启用URL重写。我使用EasyPHP 5.4.6。我正在尝试创建一个简单的重写规则(重写/ about-us / to about-us.php),它只影响一个站点(别名)。我已将.htaccess文件放在该页面的根文件夹中。我已经注意到了这些事情: 1. mod_rewrite模块在httpd.conf中加载 2. phpinfo()列出了已加载模块中的mod_rewrite 3.我的规则有效(在线测试) 4. .htaccess存储在页面的根文件夹中 5.站点的文件夹在配置文件中定义为别名 6.在该定义中,AllowOverride设置为All
猜猜看,RewriteRule不起作用,我一直收到404错误。 知道是什么导致了这个吗?
这是httpd.conf
中的别名定义Alias "/website" "C:/local/website"
<Directory "C:/local/website">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
Allow from 127.0.0.1
Deny from all
Require all granted
这是我的.htaccess
RewriteEngine On
RewriteBase /
RewriteRule ([a-zA-Z0-9\-]+)/? $1.php
答案 0 :(得分:3)
您使用的是“/ website”别名,我认为您应该在本地.htaccess文件中声明RewriteBase具有相同的值(即RewriteBase /website
)。
答案 1 :(得分:1)
我建议使用EasyPHP中的模块'Virtual Hosts Manager'。