简体   繁体   中英

how to redirect multi parameter url using htaccess

My old url is

http://www.tuitionok.com/result.php?sr=0&city=patna&text=computer+home+tuition+in+patna&type=home-tuition#t

and new url is

http://www.tuitionok.com/patna/home-tuition/computer-home-tuition-in-patna/0

I am trying to forward the old url to new

I am using this .htaccess code

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)$ result.php?city=$1&type=$2&text=$3&sr=$4 [L]

I am successfully get the parameter values and displaying the result. But the actual problem is that both old and new url is working. I think my htaccess file should be modified to redirect url forcely to the new url.

Try this:

Options +FollowSymLinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)$ result.php?city=$1&type=$2&text=$3&sr=$4 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ result.php?city=$1&type=$2&text=$3&sr=$4 [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM