skip to Main Content

I am working on seo of my website,after reading some articles i found out about seo friendly urls so i decided to change all dynamic url into static url.
for eg: most of the urls are like www.abc.com/final.php?id=1&name=name-of-file but i want to change the urls into static urls like www.a.com/name-of-file/1

I tried to edit .htaccess file but its not working.

my .htaccess file

Options +FollowSymLinks
RewriteEngine on
RewriteRule final/id/(.*)/name/(.*)/ final.php?id=$1&name=$2

2

Answers


  1. Try it like this,

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([w-]+)/([d]+)$ final.php?id=$2&name=$1 [QSA,NC,L]
    
    Login or Signup to reply.
  2. You can use:

    Options +FollowSymLinks
    RewriteEngine on
    
    # external redirect from actual URL to pretty one
    RewriteCond %{THE_REQUEST} s/+final.php?id=([^s&]*)&name=([^s&]*) [NC]
    RewriteRule ^ /%2/%1/? [R=301,L,NE]
    
    # internal forward from pretty URL to actual one
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/(d+)/? final.php?id=$2&name=$1 [NC,L,QSA]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search