mod_rewrite help

by 3 replies
4
I want to make my urls more search engine friendly.
How do I change http://www.mywebsite.com/laws.php?state=florida

to http://www.mywebsite.com/florida-laws.php

I have mod rewrite turned on, but i cant get it to work.
#programming #modrewrite
  • Well, I dont know exactly off the top how to do it as xxx-laws/
    but you can do it like this easily

    http://www.mywebsite.com/florida

    --------------------------------------------
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.*)$ laws.php?l=$1 [QSA,L]
  • im not great with these, but maybe something like this in your .htaccess file:

    RewriteRule ^([A-Za-z0-9_.-]+)-laws.php$ laws.php?state=$1 [L]

    Think that should be close.
  • If it is a Wordpress site, change your permalinks.

    Harrison

Next Topics on Trending Feed