Leonid Dubrovin
Leonid Dubrovin

Reputation: 53

Redirect in htaccess

I want redirect to print-salon.loc/land/badges/?city=moscow when I on print-salon.loc/land/badges/city-moscow and I try use this code:

# 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

but redirect does not happening.

Upvotes: 3

Views: 42

Answers (2)

Leonid Dubrovin
Leonid Dubrovin

Reputation: 53

Maybe I've described the problem incorrectly, but here's the solution

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

Upvotes: 0

Sahil Gulati
Sahil Gulati

Reputation: 15141

Try this one, hope this one will be helpful. You can test the below added lines here

Problems:

1. You skipped / in REQUEST_URI matching

2. You should use %1 instead of $1

3. You should use R flag for redirection.

<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>

Upvotes: 2

Related Questions