我只是想feature.php?ID = 1更改爲特色/ 1重寫規則不工作,mod_rewrite的啓用
mod_rewrite並根據PHP實現。我試圖把垃圾放入.htaccess文件,並給了我一個500錯誤,所以我猜這也工作。
我虛擬主機文件:我的.htaccess文件
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?feature/([a-zA-Z0-9]+)$ /feature.php?id=$1 [L,QSA]
</IfModule>
而且rewrite.log
127.0.0.1的內容
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "C:/htdocs" ServerName test2 DirectoryIndex index.php <Directory "C:/htdocs"> AllowOverride All Allow from All </Directory> RewriteLog "C:/xampp/apache/logs/rewrite.log" RewriteLogLevel 9 </VirtualHost>
內容 - - [19/Oct/2012:12:23:17 +0100] [test2/sid#2006540] [rid#66156b0/initial](3)[perdir C:/ htdocs /] strip per-dir prefix:C: /htdocs/feature.php - > feature.php
127.0.0.1 - - [19/Oct/2012:12:23:17 +0100] [test2/sid#2006540] [rid#66156b0/initial](3) [perdir C:/ htdocs /] apply pattern'^ /?feature /([a-zA-Z0-9] +)$'to uri'feature.php'
127.0.0.1 - - [19/Oct/2012 :12:23:17 0100] [TEST2/SID#2006540] [RID#66156b0 /初始](1)[perdir C:/ htdocs中/]通過C:/htdocs/feature.php
請注意,東西已從我的vhosts文件中刪除通過stackoverflow – Mladen