skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    This helps me

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

  2. With your shown samples, please try following htaccess Rules file. Please make sure you clear your browser cache before testing your URLs.

    RewriteEngine ON
    ##Rules for rewrite to section.php as per OP's request.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/?$ section.php?name=$1 [L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search