Forum Moderators: phranque
Options +FollowSymlinks
RewriteEngine on
Rewritebase /
#php_flag display_startup_errors on
#php_flag display_errors on
#php_flag html_errors on
RewriteRule ^(admin|images) - [L]
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
RewriteCond %{the_request} ^[A-Z]{3,9}\ /.*index\ HTTP/ [NC]
RewriteRule ^(.*)index http://www.domain\.com/$1 [L,R=301]
RewriteRule ^(.*)index/$ http://www.domain\.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ $1.php [L]
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+\.)+php\ HTTP
RewriteRule ^(.+)\.php$ http://www.domain.com/$1 [L,R=301]
[edited by: jdMorgan at 1:17 am (utc) on Jul 31, 2010]
[edit reason] example.com [/edit]
#php_flag display_startup_errors on
#php_flag display_errors on
#php_flag html_errors on
#
Options +FollowSymlinks
RewriteEngine on
Rewritebase /
#
# Skip all of the following rules for /admin and /images requests
RewriteRule ^(admin|images) - [L]
#
# Redirect direct client requests for /deals?url=dynamic/query to /deals/dynamic/query
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /deals(\.php)?\?url=([^&#\ ]+)
RewriteRule ^deals(\.php)?$ http://www.example.com/deals/%2? [R=301,L]
#
# Redirect direct client requests for "/index" or "/index/" or
# "/index.php" in any directory to "/" in that same directory
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]*/)*index(/|\.php)?\ HTTP/
RewriteRule ^(([^/]*/)*)index(/|\.php)?$ http://www.example\.com/$1 [R=301,L]
#
# Redirect direct client requests for .php URLs to extensionless URLs
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^.]+\.)+php\ HTTP
RewriteRule ^(.+)\.php$ http://www.example.com/$1? [R=301,L]
#
# Redirect non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Internally rewrite extensionless URL requests to .php filepaths
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1.php [L]
#
# (efficiency tweak - exclude requests with filetypes appended from 'exists' check)
RewriteCond $1 !\.[a-z][0-9]?$
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*[^/])$ /$1.php
[edited by: jdMorgan at 2:28 pm (utc) on Jul 31, 2010]