PDA

View Full Version : Help me to rewrite urls


sidra
07-04-2007, 11:06 AM
Hello,

its the first time that i am trying to rewrite url, i will be greatfull if anyone can help me

i have a website there is differnt file names different values passes to next page so can any one help me to rewrite url

here are the urls on that i am working

http://www.mysite.com/listings.php?country=USA&c=1
http://www.mysite.com/cities.php?city-of=California-USA&c=3
http://www.mysite.com/listing-in-city.php?city=Stockton&cstate=Stockton-California-USA&c=7
http://www.mysite.com/item.php?listing=Tate-Diagnostics-Stockton-California-USA&id=27&dir=7

In Actuall i want to rewrite these url like this and wants that the value will pass to the next page as it is

http://www.mysite.com/USA.php
http://www.mysite.com/California-USA.php
http://www.mysite.com/Stockton-California-USA.php
http://www.mysite.com/Tate-Diagnostics-Stockton-California-USA.php

is it possible ? if not then can any one tell me how i can rewrite these url in better way

thanks

beu
07-04-2007, 05:09 PM
Yes, use a MOD REWRITE for new URLs and then 301 redirect old URLs to new URLs.

sidra
07-04-2007, 05:28 PM
How please give me an example code that will represent one of my url ??

sidra
07-04-2007, 05:58 PM
i write this code in .htaccess for this url
http://www.mysite.com/listings.php?country=USA&c=1

Wants to rewrite it in this way
http://www.mysite.com/USA.php

Is it the right code for it, but its not giving any effect on the site and, and if its not a right code then guide me how i will write code.........thanks in advance

#start .htaccess code
RewriteEngine On
RewriteBase /www.mysite.com/

RewriteCond %{QUERY_STRING} ^country\=([^&]+)\&c\=([^&]+)$
RewriteRule ^$ /%1.php [R=301,L]

ublogtoo
07-12-2007, 05:21 PM
Hi,
try something like that:

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^country=(.*)\&c=(.*)$
RewriteRule ^(.*)$ http://www.mysite.com/%1.php [R=301,L]


uBlogToo (http://www.csimultimedia.it/)