2011-04-24 24 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

相关问题