在升级到PHP 7.0.0后,我无法在WAMP上正常运行mod_rewrite
。 Apache似乎完全忽略了所有RewriteRule
。他们导致404
错误。WAMP忽略.htaccess中的重写规则
这是我的虚拟主机httpd-vhosts.conf
:
<VirtualHost *:80>
ServerName myproject.local
DocumentRoot "D:/Projects/myproject/www"
ErrorLog "D:/Projects/myproject/www/apache_errors.log"
LogLevel info
<Directory "D:/Projects/myproject/www/">
LogLevel debug
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
这是我的.htaccess
,这是由Apache的认可,将处理像DirectoryIndex
指令,但似乎忽略任何RewriteRule
S:
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z_\-\s]+)/?$ $1.php [L,QSA] #root pages
RewriteRule ^([a-zA-Z_\-\s]+)/([a-zA-Z_\-\s]+)/?$ core/modules/$1/$2.php [L,QSA] #pages with no id
RewriteRule ^([a-zA-Z_\-\s]+)/([a-zA-Z_\-\s]+)/([0-9]+)/?$ core/modules/$1/$2.php?$1_id=$3 [L,QSA] #pages with id (edit, etc)
我的apache错误日志没有显示任何结果:只是要求失败:
[Sun Dec 18 15:47:03.787934 2016] [core:info] [pid 12532:tid 1140] [client ::1:57506] AH00128: File does not exist: D:/Projects/StoryTracker-Core/www/test
必须有一些外力,我不知道导致这些结果。
<VirtualHost *:80>
ServerName myproject.local
DocumentRoot "d:/projects/myproject/www"
ErrorLog "d:/projects/myproject/www/apache_errors.log"
LogLevel trace8
<Directory "d:/projects/myproject/www/">
Options +Indexes +FollowSymLinks +Includes
AllowOverride All
Require all granted
LogLevel trace8
</Directory>
</VirtualHost>
如果禁用“MultiViews”,会发生什么情况?它通常与重写相冲突。您应该在这些规则中使用'END'而不是'L',或者添加'DPI'。为'mod_rewrite'启用跟踪。 – Walf
@Walf当我试图访问/联系/时,我收到了这个唯一的消息。重写引擎从不会提取并重写请求。 '[Mon Dec 19 22:36:52.661022 2016] [rewrite:trace1] [pid 8204:tid 1116] mod_rewrite.c(477):[client :: 1:55336] :: 1 - - [myproject.local/sid #1fd26638ca0] [rid#1fd291c9dd0/initial] [perdir D:/ Projects/myproject/www /]通过D:/ Projects/myproject/www/contact' –
我应该得到一个'init rewrite engine with requested uri' then'向uri'/ contact /''应用模式'^([a-zA-Z _ \\ - \\ s] +)/?$',但我不知道为什么'init rewrite engine'永远不会触发 –