2017-08-25 111 views
3

我想重定向到print-salon.loc/land/badges/?city=moscow當我print-salon.loc/land/badges/city-moscow,我嘗試使用此代碼:重定向htaccess的

# BEGIN WPSuperCache 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

AddDefaultCharset UTF-8 
RewriteCond %{REQUEST_URI} ^land/badges/city-([a-zA-Z]+)$ 
RewriteRule ^(.*) /land/badges/index.php?city=$1 [L] 

</IfModule> 
# END WPSuperCache 

但重定向不會發生。

回答

2

試試這個,希望這個會有幫助。您可以測試下方添加的行here

問題:

您在REQUEST_URI跳過/匹配

2.您應該使用%1代替$1

3.您應該使用R標誌進行重定向。

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

AddDefaultCharset UTF-8 
RewriteCond %{REQUEST_URI} ^/land/badges/city-([a-zA-Z]+)$ 
RewriteRule ^(.*) /land/badges/index.php?city=%1 [L,R] 

</IfModule> 
0

也許我描述不正確的問題,但這裏的解決方案

RewriteRule ^land/([-a-zA-Z0-9]+)/city-(.*)$ http://%{HTTP_HOST}/land/$1/index.php?city=$2 [L]