Forum Moderators: phranque
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /scripts/gateway.php?action=SomeStaticAction§ion=$1 [NC]
# All .html URLs should go internally redirect to the scripts/gateway.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /scripts/Gateway.php?action=TextAction§ion=$1 [NC]
# test to 301 the old URLs to the clean ones
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{REQUEST_URI} ^/scripts/(.*)
RewriteCond %{QUERY_STRING} ^.*section=([a-zA-Z]+).*$
RewriteRule ^scripts/Gateway.php$ /%1.html? [R=301,L]
[edited by: g1smd at 1:25 pm (utc) on Jul 16, 2010]
# All other should go to the scripts/gateway
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.*)\.html$
RewriteRule ^(.*)\.html$ /scripts/Gateway.php?action=TextAction§ion=$1 [L]
# test to get only the clean URLs
RewriteCond %{THE_REQUEST} ^.*scripts/.*
RewriteCond %{REQUEST_URI} ^/scripts/(.*)
RewriteCond %{QUERY_STRING} ^.*section=([a-zA-Z]+).*$
RewriteRule ^scripts/Gateway.php$ /%1.html? [R=301]
RewriteCond %{THE_REQUEST} ^.*scripts/.*
# external 301 redirect old URLs to the clean ones
RewriteCond %{THE_REQUEST} ^.*scripts/(.*)section=([a-zA-Z]+).*
RewriteRule ^scripts/Gateway.php$ /%2.html? [R=301,L]
# www canonicalization
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# All .html URLs should internally rewrite to the scripts/gateway.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z]+)\.html$ /scripts/Gateway.php?action=TextAction§ion=$1 [NC,L]
[edited by: engine at 7:47 am (utc) on Jul 22, 2010]
[edit reason] member requested domain obfuscation [/edit]
RewriteRule ^(.*)\.html$ /scripts/gateway.php?action=SomeStaticAction§ion=$1 [NC]
^(.*)\.html$
^ = beginning of the string to test
(.*) = any number of any character(s) placed in a match container
\. = escape the period (checks for a period, not 'any character')
html = string 'html'
$ = end of the string to test
/scripts/gateway.php?action=SomeStaticAction§ion=$1 [NC]
/scripts/gateway.php?action=SomStaticAction§ion= = INCLUDE this string
$1 = referencing the contents of the first match container in the PATTERN ((.*))
[NC] = case-insensitive
# externally redirect direct client requests for old URLs to new clean ones
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /scripts/Gateway\.php\?([^&]*&)*section=([A-Za-z]+)(&[^\ ]*)?\ HTTP/
RewriteRule ^scripts/Gateway\.php$ http://www.example.com/%2.html? [R=301,L]
#
# externally redirect non-blank non-canonical hostname requests to canonical www host
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# internally rewrite all .html URLs to scripts/gateway.php with filename passed as query parameter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z]+)\.html$ /scripts/Gateway.php?action=TextAction§ion=$1 [L]