Search code examples
.htaccessurlmod-rewriteurl-rewritingfriendly-url

Rewrite url for seo friendly htaccess


I want to rewrite this in SEO friendly url.

From - www.example.com/section.php?name=website

To - www.example.com/section/website

I tried this:

RewriteEngine On
RewriteRule ([^/\.]+)/([^/\.]+)?$ section.php?type=$1&service=$2 [NC,L]

I am fetching data using GET method in section.php and pass to the another page but after opening sub folder like www.example.com/{foldername} it returns to the section.php

Thanks. I will appreciate your help.


Solution

  • This helps me

    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    RewriteRule ([^/\.]+)/([^/\.]+)/?$ search.php?type=$1&service=$2