Search code examples
.htaccess

changing URL by .htaccess


I have pages of this type :-

xyz.com?q=Apple+Ipod+touch

I wish to convert it into type

xyz.com/Apple+Ipod+touch

How can this be done ?


Solution

  • Try:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
    

    If you have a more specific format of the URLs, you may be able to refine the RewriteRule to be less generic (i.e. not match everything) and more specific to your URLs, but this should work.