0

Possible Duplicate:
.htacces to create friendly URLs. Help needed

I want to build a script like WordPress for the "nice urls", i copied the .htaccess rows and made some modifications, but on the side of the PHP i don't know how to build it.

I don't understand how it works.

Community
  • 1
  • 1

2 Answers2

0

With the help of Daniel A White i found the class in WordPress files.

WP_Rewrite: http://xref.wordpress.org/trunk/WordPress/Rewrite/WP_Rewrite.html

0

Start with setting rewrite engine and follow sym links

RewriteEngine On

# Drop the .php --  or any other extension you use.
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

#Forces the site to switch to www.site.com - change the site/TDL below
RewriteCond %{HTTP_HOST} ^insuranceiwant\.com$
RewriteRule (.*) http://www.insuranceiwant.com/$1 [R=301,L]

Now name your pages something useful like site.com/contact-us If you are pulling dynamic pages from a database, also add this:

Options +FollowSymLinks
Options +Indexes
RewriteRule ^([A-Za-z_]+)_([A-Z]+)/([A-Za-z0-9_-]+)$ /Resources/city.php?state=$1&region=$2&city=$3

That example shows that the dynamic page has a state name, state abbreviation, and a city pulling from the database and showing the page like so: insuranceiwant.com/California_CA/Los_Angeles

For more information on regular expresion for your page names check out this useful site: http://www.regular-expressions.info/

Eric Leroy
  • 1,830
  • 1
  • 18
  • 31