Forum Moderators: phranque
I have been tryign to solve this with the help of Webmaser World and other forums but somehow could not get any success. May be some experience user can help me on this.
I have some urls at a site with the format
http://www.mydomain.com/results.php?term=search_term
Here are my questions
1.) How can I make the URLS appear like this in the user browsers
http://www.mydomain.com/search_term.html
2.) Do I have to change the links manually on my site from http://www.mydomain.com/results.php3?term=search_term to http://www.mydomain.com/search_term.html OR will it be done automatically.
Looking forward for your help. In the meanwhile I will keep digging and trying to solve it myself :)
2.) Do I have to change the links manually on my site from http://www.mydomain.com/results.php3?term=search_term to http://www.mydomain.com/search_term.html OR will it be done automatically.
Yes, anything that feeds URLs to the browser should be changed to specify the new short URL, and then let mod_rewrite translate that short URL back into the long one if it is required for input by your script.
Jim
Tried everything, but so far no luck. Now my .htaccess looks like this
RewriteEngine on
RewriteBase /mod
RewriteRule ^(.*)mod/(.*)\.html$ http://www.mydomain.com/results.php3?term=$2 [R=301,L]
I am testing it in a subdirectory so that I dont mess up with my main site.
Please correct me if I am wronge. In my opinion the above should convert any URLS even non existing to the later one.
Example
If someone tries for
http://www.mydomain.com/mod/search.html
It should be converted to
http://www.mydomain.com/results.php3?term=search
Instead of doing this the URL it is picking up is my 404 page.
Thanks for helping me out.
Finally successful, the final code looks like this
RewriteEngine on
RewriteBase /mod
RewriteRule (.*).html$ http://www.mydomain.com/results.php3?term=$1 [R=301,L]
Now when I try to access http://www.mydomain.com/mod/anything.html it automatically transfers me to http://www.mydomain.com/results.php3?term=anything
Now coming back to the small hitch
The URL in the browser also displays as http://www.mydomain.com/results.php3?term=anything
Is there any way that the URL remains the same as http://www.mydomain.com/mod/anything.html