简体   繁体   中英

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.

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]

This helps me

RewriteEngine On

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM