2011-04-24 44 views
0

我有我的網頁重定向如下:的.htaccess重定向 - 更改文件名和查詢字符串命令

,如果我有

mysite.com/abc.php?id=12345 

我要重定向到

mysite.com/def/12345.html 

如果我有

mysite.com/abc.php?id=55626 

我得重新搜索噸至

mysite.com/def/55626.html 

請告知

=================================== ==================

下面的代碼解決我的問題

Options +FollowSymlinks 
RewriteEngine on 
RewriteCond %{QUERY_STRING} ^id=(.*)$ 
RewriteRule ^abc\.php$ http://mysite.com/def/%1.html? [R=301,L] 
+0

那你試試到目前爲止,什麼是錯的? – 2011-04-24 15:52:02

+0

使用'.php'指示我,作爲一個查看器,有PHP腳本驅動的事情。那麼爲什麼你使用'.htaccess'而不是'header()'? – 2011-04-24 15:52:52

+0

我沒有使用重定向規則的經驗。 abc.php和def都是.php文件。 12345.html是查詢字符串。 我需要我的路徑看起來像一個靜態頁面.html埠它仍然.php文件 – Igal 2011-04-24 16:21:11

回答

0
Options +FollowSymlinks 
RewriteEngine on 
RewriteRule ^def/([^/]+).html /abc.php?section=$1 [NC] 
+0

這不適合我。 – Igal 2011-04-24 16:36:02

+1

你正在做Igal要求的相反... – nitro2k01 2011-04-24 17:23:08

相關問題