2015-09-25 124 views
2

公開賽:zalora-kupon-kode-diskon-voucher-promosi/重定向舊的URL到新的URL,但舊的URL顯示在新的URL

結果:http://www.situskupon.com/toko/zalora_indonesia-2.html?zalora-kupon-kode-diskon-voucher-promosi

,你會發現後,舊的URL?

有什麼不對?

這是我的htaccess:

# Follow symbolic links in this directory. 
 
Options +FollowSymLinks 
 
IndexOptions +Charset=UTF-8 
 
AddDefaultCharset UTF-8 
 

 
RewriteEngine on 
 

 
RedirectMatch 301 zalora-kupon-kode-diskon-voucher-promosi/ http://www.situskupon.com/toko/zalora_indonesia-2.html 
 
RedirectMatch 301 lazada-kupon-kode-diskon-voucher-promosi/ http://www.situskupon.com/toko/lazada_indonesia-3.html 
 
RedirectMatch 301 hostgator-kupon-kode-diskon-voucher-promosi/ http://www.situskupon.com/toko/hostgator-5.html 
 

 
RewriteCond %{HTTP_HOST} ^situskupon\.com [OR] 
 

 
RewriteCond %{REQUEST_FILENAME} !-f 
 
RewriteCond %{REQUEST_FILENAME} !-d 
 

 
RewriteRule ^([a-zA-Z0-9-_]+)/$ index.php?$1 [QSA,L] 
 

 
## This should be a normal page 
 
RewriteCond %{REQUEST_FILENAME} !-f 
 
RewriteRule ^([a-zA-Z0-9-_]+)-(\d+).html$ index.php?pages=$2 [QSA,L] 
 

 
## This should be a page from the theme 
 
RewriteCond %{REQUEST_FILENAME} !-f 
 
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9-_]+)-(\d+).html$ index.php?$1=$3 [QSA,L] 
 

 
## This should be a page from theme 2 
 
RewriteCond %{REQUEST_FILENAME} !-f 
 
RewriteRule ^([a-zA-Z0-9-_]+).html$ index.php?tpage=$1 [QSA,L] 
 

 
## This should be a plugin 
 
RewriteCond %{REQUEST_FILENAME} !-f 
 
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9-_]+).(php|html|xml)$ index.php?$1=$2&ext=$3 [QSA,L] 
 

 
ErrorDocument 403 /index.php 
 
ErrorDocument 404 /index.php 
 
ErrorDocument 500 /index.php

回答

2

的問題是,你是混合mod_alias中(RedirectMatch)和mod_rewrite的(RewriteRule)指令和有衝突。不同的模塊在不同的時間運行,這不一定與指令出現在.htaccess文件中的順序相同。

會發生什麼情況是,下面的內部重寫觸發第一,因爲這也是URL匹配:

RewriteRule ^([a-zA-Z0-9-_]+)/$ index.php?$1 [QSA,L] 

然後你RedirectMatch觸發後,產生重定向你所看到的。

解決方案...不要在兩個模塊中混合重寫/重定向。更改mod_alias中重定向到使用mod_rewrite來代替:

例如:

RewriteRule ^zalora-kupon-kode-diskon-voucher-promosi/$ http://www.situskupon.com/toko/zalora_indonesia-2.html [R=301,L] 

請注意,您將需要清除瀏覽器緩存,因爲301重定向緩存。由於這個原因,使用302(臨時)重定向進行首次測試會更容易。

+0

你好,這個解決方案運作良好。解決。 –

+0

很高興爲你效勞。爲了表明問題已解決,請將答案標記爲「已接受」(點擊左側的勾號)。然後,這個問題從未答覆的問題隊列中解決。非常感謝,謝謝。 – MrWhite