Nice URLs

# Title: `.htaccess` Rules For Nice URLs # Author: [Abe](http://snipplr.com/users/Abe) # Source: [Snipplr](http://snipplr.com/view/4562/nice-urls-php-htaccess) RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ## Option 1: UNCOMMENT LINE BELOW TO USE ## RewriteRule ^(.*)$ $1.php [L,QSA] ## Option 2: UNCOMMENT LINE BELOW TO USE ## RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Remove file extension or use query strings like virtual directories.

Remove file extension: http://domain/about.php -- becomes -- http://domain/about

Virtual directories: http://domain/index.php?q=about -- becomes -- http://domain/about

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.