2016-11-17 55 views
0

爲了編輯我的實際URL結構。我需要重定向我的「舊」鏈接以保持傳入鏈接處於活動狀態。已重定向已使用參數重寫URL

一切工作正常,但它不工作時,「舊」的鏈接有參數。

這裏是我的.htaccess的第一部分(這是工作):

Options +FollowSymlinks -MultiViews 
RewriteEngine On 

# Rewrite the "old" url "/models" to "/models-pictures" 
RewriteRule ^/?models/?$ /models-pictures [R=301,NE,L] 

# New redirection 
RewriteCond %{REQUEST_URI} /models-pictures/?$ [NC] 
RewriteRule . models.php [L] 

而現在未重定向第二部分

# Rewrite the "old" url "/models/[name]-pictures" to "/[name]-pictures" 
RewriteRule ^/?models/([a-z\-A-Z]+)-pictures/?$ /%1-pictures [R=301,NE,L] <- Not working 

# New redirection 
RewriteCond %{REQUEST_URI} /([a-z\-A-Z]+)-pictures/?$ [NC] 
RewriteRule . orderby.php?model=%1 [L,QSA] 

# New redirection 
RewriteCond %{REQUEST_URI} /([a-z\-A-Z]+)-pictures/([a-z\-A-Z]+)/?$ [NC] 
RewriteRule . p.php?model=%1&media=%2 [L,QSA] 

任何想法?謝謝。

+1

在'/ $ 1-pictures'中使用'$ 1'而不是'%1' – Croises

回答

1

您沒有在非工作規則中的替換字符串中使用正確的反向引用。您有%1,它應該是$1

# Rewrite the "old" url "/models/[name]-pictures" to "/[name]-pictures" 
RewriteRule ^/?models/([a-z\-A-Z]+)-pictures/?$ /$1-pictures [R=301,NE,L]