多个参数URL重定向到另一个preety URL

时间:2014-06-12 07:41:48

标签: .htaccess

我想通过htaccess重定向:
     test.mydomain.com/articles_main.php?post=POSTTILE&name=&email =

要:
     mydomain.com/POSTTILE

非常感谢任何帮助,我很长时间都在努力,请帮忙。

编辑: 我已经测试了很多东西但是评论的是:

RewriteEngine On
RewriteBase
RewriteCond %{THE_REQUEST} \s/articles_main.\.php\?post=([^&]*)&name=([^&]*)&email=([^&]*) [NC]
RewriteRule ^articles_main\.php\?post=([A-Za-z0-9-]+)&name=&email=$ http://mydomain.com/$1 [L,R=301]
RewriteRule ^articles_main\.php\?post=([A-Za-z0-9]+)&?$ ^/$1/?$ [R=301]

1 个答案:

答案 0 :(得分:0)

你的正则表达式不正确。使用此代码:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^test\.mydomain\.com$ [NC]
RewriteCond %{THE_REQUEST} \s/articles_main\.php\?post=([^&]+)&name=([^&]*)&email=([^&\s]*) [NC]
RewriteRule ^ http://mydomain.com/$1? [L,R=301]

RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^([A-Za-z0-9]+)/?$ articles_main\.php?post=$1name=&email= [L,QSA]