WAMP忽略.htaccess中的重写规则

时间:2016-12-18 21:38:00

标签: .htaccess mod-rewrite apache2 wamp apache2.4

升级到PHP 7.0.0后,我无法让Visit visit1; Visit visit2; @After public void clear(){ if (visit1 != null) this.entityManager.remove(visit1); if (visit2 != null) this.entityManager.remove(visit2); this.entityManager.flush(); } 在WAMP上正常运行。 Apache似乎完全忽略了所有mod_rewrite。它们会导致RewriteRule错误。

这是404中的虚拟主机:

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> ,它被Apache识别,将处理像.htaccess这样的指令,但似乎忽略了任何DirectoryIndex

RewriteRule

我的apache错误日志没有显示任何后果:只是该请求失败:

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)

必须有一些外力,我不知道造成这些结果。

修改 我已经按照以下方式更新了我的虚拟主机,但无济于事:

[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

1 个答案:

答案 0 :(得分:1)

mod_rewrite不喜欢项目目录名中的破折号。

在使用-重新命名项目路径中的目录后,我能够从LogLevel debug rewrite:trace8找出其余问题。