Forum Moderators: phranque
http://www.example.com/factsheets/workplace/industrial-safety
http://www.example.com/library/topical-index
http://www.example.com/factsheets/pdfs/workplace-safety-programming.pdf-> should NOT redirect
RewriteEngine on
RewriteBase /
#Exceptions to rewrite rules
RewriteRule ^(phaseout)($|/) - [L]
#Control user navigation quirks (like just deleting parts of the link)
redirect 301 /index.htm http://www.example.com
redirect 301 /default.htm http://www.example.com
redirect 301 /default.html http://www.example.com
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteRule ^(.*)index.html$ http://www.example.com/$1 [R=301,L]
#Ensure the website is always addressed as www.hazardcontrol.com
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
ErrorDocument 404 /sitemanagement/404
ErrorDocument 403 /sitemanagement/403
... (a bunch of redirect 301 rules to keep search engine rank from the old site) ...
#Rewrite dynamic URIs as static/flat URIs for user ease and search engine happiness
RewriteRule ^factsheets/([^/\.]+)/([^/.]+)$ view.php?fs=$1&p=$2 [L]
RewriteRule ^factsheets/([^/.]+)/([^/.]+).php$ view.php?fs=$1&p=$2 [L]
RewriteRule ^factsheets/([^/.]+)/([^/.]+).htm$ view.php?fs=$1&p=$2 [L]
RewriteRule ^factsheets/([^/.]+)/([^/.]+).html$ view.php?fs=$1&p=$2 [L]
RewriteRule ^([^/.]+)/([^/.]+)$ view.php?f=$1&p=$2 [L]
RewriteRule ^([^/.]+)/([^/.]+).php$ view.php?f=$1&p=$2 [L]
RewriteRule ^([^/.]+)/([^/.]+).htm$ view.php?f=$1&p=$2 [L]
RewriteRule ^([^/.]+)/([^/.]+).html$ view.php?f=$1&p=$2 [L]
RewriteEngine on
RewriteBase /
#Exceptions to rewrite rules
RewriteRule ^(phaseout)($|/) - [L]
#Control user navigation quirks (like just deleting parts of the link)
redirect 301 /index.htm http://www.example.com
redirect 301 /default.htm http://www.example.com
redirect 301 /default.html http://www.example.com
# -> Prevent users from accessing another domain name
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,N]
# -> Prevent users from trying to access the 'index page' of a folder or section
RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteRule ^(.*)index.html$ http://www.example.com/$1 [R=301,N]
# -> Ensure the website is always addressed as www.example.com
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,N]
#Custom error docs
ErrorDocument 404 /sitemanagement/404
ErrorDocument 403 /sitemanagement/403
#Maintain legacy search engine page ranks by redirecting them to our new pages
...(the same redirect 301 rules as the original htaccess file) ...
#Rewrite dynamic URIs as static/flat URIs for user ease and search engine happiness
RewriteRule ^(\.pdf)$ - [L]
RewriteRule ^factsheets/([^/\.]+)/([^/\.]+)(.*)$ view.php?fs=$1&p=$2 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)(.*)$ view.php?f=$1&p=$2 [L] [edited by: bmen at 1:54 am (utc) on Jun 7, 2012]
I thought I had read the charter, but missed that point. Sorry! I edited my post to remove all specific names, and to remove all the irrelevant redirect statements. Thanks for alerting me to my error.
# -> Ensure the website is always addressed as www.example.com
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,N]
redirect 301 /index.htm http://www.example.com
^factsheets/([^/\.]+)/([^/\.]+)(.*)$ view.php?fs=$1&p=$2 [L]
RewriteRule ^factsheets/([^/\.]+)/([^/.]+)$ view.php?fs=$1&p=$2 [L]
RewriteRule ^factsheets/([^/.]+)/([^/.]+).php$ view.php?fs=$1&p=$2 [L]
RewriteRule ^factsheets/([^/.]+)/([^/.]+).htm$ view.php?fs=$1&p=$2 [L]
RewriteRule ^factsheets/([^/.]+)/([^/.]+).html$ view.php?fs=$1&p=$2 [L]
RewriteRule ^([^/.]+)/([^/.]+).php$ view.php?f=$1&p=$2 [L]
{blahblah}(\.(php|htm?))?$
{blahblah}(\.(php|html?))?$
RewriteEngine on
RewriteBase /
RewriteRule ^(\.pdf)$ - [L]
#RewriteCond %{THE_REQUEST} ^factsheets/.* [NC]
RewriteRule ^factsheets/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)(\.(php|htm?))?$ view.php?fs=$1&p=$2 [L]
#RewriteCond %{THE_REQUEST} ^(about|copyright|library|products|sitemanagement)/.* [NC]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)(\.(php|htm?))?$ view.php?f=$1&p=$2 [L]
#RewriteRule ^(([^/]+/)*)index\.htm$ http://www.example.com/$1 [R=301,L]
#RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [NC]
#RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] (\.(php|htm?))?$ (\.(php|html?))?$ RewriteRule ^(\.pdf)$ - [L] www.example.com/.pdf