.htaccess 301重定向无法正常工作

时间:2016-10-07 23:08:32

标签: apache .htaccess redirect mod-rewrite

我正在尝试设置一个.htaccess文件来重定向我已从服务器上删除页面的旧网址(不确定这是否是问题)。我正在尝试将页面重定向到具有相同内容的新页面。谁能告诉我为什么这不起作用? (我相信它应该)跟随几个在线指南。

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com/wheels_landing_page.php [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com/wheels_landing_page.php [NC]
RewriteRule ^(.*)$ http://example.com/wheelsLanding.php/$1 [L,R=301,NC]

RewriteCond %{HTTP_HOST} ^example.com/dealerships.php [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com/dealerships.php [NC]
RewriteRule ^(.*)$ http://example.com/contact.php/$1 [L,R=301,NC]

1 个答案:

答案 0 :(得分:1)

尝试:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^wheels_landing_page\.php(.*)$ http://example.com/wheelsLanding.php$1 [L,R=301,NC]

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^dealerships\.php(.*)$ http://example.com/contact.php$1 [L,R=301,NC]