Forum Moderators: phranque
http://www.somesite.co.uk/?http://www.somesite.co.uk/ Options +FollowSymlinks
RewriteEngine on
# Externally redirect direct client requests for script filepaths back to "friendly" extensionless URLs
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]*/)*[^.]+\.php([?#][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*[^.]+)\.php$ /$1/ [R=301,L]
# Externally redirect to add missing trailing slashes to extensionless URL requests
RewriteCond $1 !\.[a-z]+[0-9]?$
RewriteRule ^(.*[^/])$ http://www.somesite.co.uk/$1/ [R=301,L]
# Externally redirect all non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} !^www\.somesite\.co\.uk$
RewriteRule ^(.*)$ http://www.somesite.co.uk/$1 [R=301,L]
# Internally rewrite all requests ending with slash to php scripts
RewriteRule ^(.*)/$ /$1.php [L]
# Externally redirect direct client requests for script filepaths back to "friendly" extensionless URLs
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]*/)*[^.]+\.php([?#][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*[^.]+)\.php$ http://www.somesite.co.uk/$1/ [R=301,L]
# Externally redirect requests for the URL-path
# /<anything-or-nothing>?http://www.somesite.co.uk<something_or_blank> to
# http://www/somesite.co.uk/<anything-or-nothing>
RewriteCond %{QUERY_STRING} ^http://www\.somesite\.co\.uk
RewriteRule ^(.*)$ http://www.somesite.co.uk/$1? [R=301,L]