3

My old url is

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

and new url is

http://www.website.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.

1 Answer 1

2

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]
Sign up to request clarification or add additional context in comments.

6 Comments

it is not redirecting to new url
You have to change the variables value having space by hypen like $type = str_replace(' ','-', $type);
there is no space in variable i also used this url tuitionok.com/… but not redirecting
Can you show the php code so i can understand what you actually doing?
here is the query code in php $query="select * from organisation where type='$type' and display=1 and $city like '%$city%' and keyword like '%$text%' limit $sr, 10";
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.