在htaccess中重写url或重定向url

时间:2015-01-05 22:49:08

标签: redirect

我正在尝试重定向或重写特定页面。在我的.htaccess中,我尝试了这两条线,但都没有奏效。新闻发布 - 新闻/?lang = en页面存在于我的网站上,但没有/ press-releases-news /?lang = fi,所以我试图避免产生的404。在这里欣赏一些指示。

Redirect 301 /press-releases-news/?lang=fi/ /press-releases-news/?lang=en
RewriteRule    /press-releases-news/?lang=fi/  /press-releases-news

在RewriteEngine On后直接放置

<IfModule mod_rewrite.c>
RewriteEngine On
Redirect 301 /press-releases-news/?lang=fi/ /press-releases-news/?lang=en
RewriteRule    /press-releases-news/?lang=fi/  /press-releases-news
RewriteBase /
RewriteRule ^(.+)\.aspx?$ handleRedirect.php [L,NC] 
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

1 个答案:

答案 0 :(得分:0)

尝试:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{QUERY_STRING} lang=fi
RewriteRule ^press-releases-news http://yourdomain.com/press-releases-news [R=301]