我已经阅读了关于htaccess重定向和重写stackoverflow和其他网站上的内容,并了解了如何重定向简单的页面和目录,但仍有大约30个链接,我无法重定向。原因似乎是因为它们在链接的URL中包含“?”。我已尝试过发布的解决方案,但我无法对它们取得足够的成功感。
这些工作:
Redirect /Corpfleet.php htp://www.marketyourcar.cm/wraps.php
Redirect /drivers.php htp://www.marketyourcar.cm/drivers.php
Redirect /galleries.php htp://www.marketyourcar.cm/galleries.php
这些不起作用:
Redirect /ad.php?View=FAQ htp://www.marketyourcar.cm/advertiser-faqs.php
Redirect /ad.php?View=gallery htp://www.marketyourcar.cm/galleries.php
Redirect /ad.php?View=Materials htp://www.marketyourcar.cm/products-services.php
是的,我知道上面的网址是htp和.cm - 我不得不打破它以便以低信誉级别发布此帖子。
如果有人可以帮助我,我会很感激。 感谢
答案 0 :(得分:2)
如果您想从以下方式重定向:
site.com/index.php?blabla=1&id=32
到
<强> site.com/contact.html 强>
然后使用:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} blabla=1&id=32
RewriteRule ^(.*)$ http://www.site.com/contact.html? [R=301,L]
</IfModule>
答案 1 :(得分:1)
Redirect
无法处理。 RewriteRule
可以。这应该有用。
RewriteEngine on
RewriteRule ^/ad\.php\?View\=FAQ$ http://www.marketyourcar.cm/advertiser-faqs.php [R=301,L]
RewriteRule ^/ad\.php\?View\=gallery$ http://www.marketyourcar.cm/galleries.php [R=301,L]
RewriteRule ^/ad\.php\?View\=Materials$ http://www.marketyourcar.cm/products-services.php [R=301,L]
或试试这个:
RewriteEngine on
RewriteRule ^/ad.php?View=FAQ$ http://www.marketyourcar.cm/advertiser-faqs.php [R=301,L]
RewriteRule ^/ad.php?View=gallery$ http://www.marketyourcar.cm/galleries.php [R=301,L]
RewriteRule ^/ad.php?View=Materials$ http://www.marketyourcar.cm/products-services.php [R=301,L]
答案 2 :(得分:0)
这可能有效:
示例:
RewriteEngine On
RewriteRule ^/ad.php?View=FAQ$ http://www.marketyourcar.cm/advertiser-faqs.php? [R=301,L]
在替换网址中添加一个尾随?
以删除传入的查询。