2011-09-24 53 views
1

我有一個帶查詢字符串的查詢URL,我想將它轉換爲文件夾結構化的URL。.htaccess將查詢字符串轉換成文件夾格式

例如:

http://localhost/index.php?page=about-us 
http://localhost/index.php?page=contact-us 

我怎麼會是隱蔽到

http://localhost/index/page/about-us 
http://localhost/page/about-us 

我知道這可以用的.htaccess來完成。我只是不知道從哪裏開始

+1

檢查:http://stackoverflow.com/questions/1231067/htaccess-rewrite-for -請求參數 –

回答

0

您需要沿着線的東西...

Options +FollowSymLinks 
RewriteEngine On 

RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f 

RewriteRule ^page/([-a-z-0-9]+)*/$ ./index.php?page=$1 
RewriteRule ^index/page/([-a-z-0-9]+)*/$ ./index.php?page=$1