Forum Moderators: phranque
<Files ~ "\.(tpl|txt)$">
Order deny,allow
Deny from all
</Files>
# DirectoryIndex and RewriteEngine
DirectoryIndex index.php index.html
RewriteEngine On
Options -Indexes +FollowSymLinks
# Redirect .htm requests to .html and force non-www at the same time
# (force addition of hyphen in two "paged" rules; hyphen is no longer optional)
RewriteRule ^(directory/((latest|premium)-links|top-hits|(contact|link)us))\.htm$ http://example.com/$1.html [R=301,L]
RewriteRule ^(directory/detail/link)-?([0-9]+)\.htm$ http://example.com/$1-$2.html [R=301,L]
RewriteRule ^(directory/info/[0-9]+[^/.]+)\.htm$ http://example.com/$1.html [R=301,L]
RewriteRule ^(directory/[^/]+/page)-?([0-9]+)\.htm$ http://example.com/$1-$2.html [R=301,L]
# Redirect to force hyphens in paged .html requests (hyphen no longer optional)
RewriteRule ^(directory/detail/link)([0-9]+)\.html$ http://example.com/$1-$2.html [R=301,L]
RewriteRule ^(directory/[^/]+/page)([0-9]+)\.html$ http://example.com/$1-$2.html [R=301,L]
# Site-wide www to non-www canonicalisation
RewriteCond %{HTTP_HOST} !^(example\.com)?$
RewriteRule (.*) http://example.com/$1 [R=301,L]
# RewriteBase
RewriteBase /directory
# Internal rewrites for valid .html requests. For "paged" URLs hyphen is required.
RewriteRule ^directory/latest-links\.html$ index.php?l=l [L]
RewriteRule ^directory/premium-links\.html$ index.php?pm=l [L]
RewriteRule ^directory/top-hits\.html$ index.php?list=top [L]
RewriteRule ^directory/(contact|link)us\.html$ $1us.php [L]
RewriteRule ^directory/detail/link-([0-9]+)\.html$ detail.php?id=$1 [L]
# (also need to modify PHP script to check $slug variable
# is valid for requested $br value in next rule)
RewriteRule ^directory/info/([0-9]+)([^/.]+)\.html$ info.php?br=$1&slug=$2 [L]
RewriteRule ^directory/([^/]+)/page-([0-9]+)\.html$ index.php?uri=$1&p=$2 [QSA,L]
# Internal rewrite
RewriteCond %{REQUEST_URI} --need pattern here to pre-check request so that only URLs that will be rewritten need to be "-f" and "-d" checked for clashes--
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^directory/([^/]+/)+$ index.php?uri=$1 [QSA,L]
# The above line is a guess. You might need this instead:
RewriteRule ^directory/([^/]+)/$ index.php?uri=$1 [QSA,L]
# However if the above URLs are for "pages" then the extensionless
# URL should not end with a slash at all. <IfModule mod_rewrite.c>
</IfModule> RewriteRule ^directory/(.*)/$ index.php?uri=$1 [QSA,L] RewriteRule ^directory/([^/]+/)+$ index.php?uri=$1 [QSA,L] RewriteRule ^directory/([^/]+/)*[^/.]+)$ index.php?uri=$1 [QSA,L]