我有一個網站,我試圖使用mod_rewrite從網址更改:的.htaccess mod_rewrite的通用規則
/directory/filename.php
到directory/filename/
/directory/filename.php?id=7
到directory/filename/7/
/directory/filename.php?id=7&file_id=1
到directory/filename/7/1/
我儘管如此,我無法制定正則表達式來用於這些頁面。這裏是整個.htaccess文件:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^(.*)/?$ /directory/$1 [L] #Rewrite a page without $_GET variables
RewriteRule ^([^/]+)/([0-9]+)/?$ /directory/$1?id=$2 [L] #Rewrite a page with 1 $_GET variables
RewriteRule ^([^/]+)/([0-9]+)/([0-9]+)/?$ /directory/$1?id=$2&file_id=$3 [L] #Rewrite a page with 2 $_GET variables
是在'directory'或'root'文件夾中的.htaccess? – 2012-01-27 11:28:26
在目錄文件夾中 – 2012-01-27 11:32:09
你的意思是你想從**'foo/bar /'**重寫(請求)**到**'foo/bar.php'的另一種方式? – Qtax 2012-01-27 11:32:39