2013-01-24 35 views
1

我看了一下htaccess的重定向和重寫的計算器和其他網站和學會了如何重定向頁面簡單和目錄,但也有剩餘,我一直無法重定向約30個鏈接。原因似乎是因爲它們在鏈接的URL中包含「」。我已經嘗試了所發佈的解決方案,但我一直無法讓他們有足夠的理解來取得成功。如何在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

我認爲我的問題的一部分是,我給你們的實時服務器信息,而不是開發服務器信息。我不在現場測試這個代碼,所以我必須編輯一切,以適應開發設置: 這些文件坐在這裏: 'http:// clients.lancedaoust.com/myc /' 所以我' VE編輯你給了我,以適應代碼: '重寫規則/myc/ad.php?View=FAQ$ http://www.marketyourcar.com/advertiser-faqs.php [R = 301,L]' –

回答

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] 
+0

謝謝,我只是嘗試過,但沒有奏效:它產生了404 「未找到 請求的URL /ad.php此服務器上找到。」 –

+0

你確定你在你的Apache設置中啓用了'mod_rewrite'嗎?另外,請查看本頁右側的相關鏈接。我發佈的內容和其他提示的組合應該可以工作。 – JakeGould

+0

我只是遵循了關於如何使用mod_rewrite的教程,它的工作原理,所以我會說是的,它已啓用。 –

0

這可能會實現:

例子:

RewriteEngine On 
RewriteRule ^/ad.php?View=FAQ$ http://www.marketyourcar.cm/advertiser-faqs.php? [R=301,L] 

添加尾隨?來替代URL刪除傳入查​​詢。

1

如果你想從像重定向:

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>