Forum Moderators: phranque
redirectMatch 301 ^/orderform_files/www/ /sitemap.php # Redirect index.html and .htm to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.example.com/$1 [R=301,L]
# Redirect non-canonical to www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
\.html? part to specify actual extensions in use, such as .php and so on. The question mark is needed only if you want to match both index.ph and index.php requests.So it is not wrong to leave the question mark in - for safety?
Don't forget there are two places within the ruleset that need to be modified in exactly the same way.yes, they are both index\.html?
You can also use the "|" OR operator to cater for both .html and .php requests.Like this?
*index\.html?\ |*index\.php?\ HTTP/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(php|html?)\ HTTP/
RewriteRule ^(([^/]+/)*)index\.(php|html?)$ http://www.example.com/$1 [R=301,L] # Redirect index.php and .ph or html and .htm to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(php|html?)\ HTTP/
RewriteRule ^(([^/]+/)*)index\.(php|html?)$ http://www.example.com/$1 [R=301,L]
# Redirect non-canonical to www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L] ^[A-Z]{3,9}\ / and \ HTTP/ when looking at THE_REQUEST with a RewriteCond. The bit in between those items is then an exactly specified path, and if you don't make provision for parameters, requests with parameters will not be matched. ^[A-Z]{3,9}\ also reminds you that all methods are being processed. Sometimes you might replace that with the literal GET or POST or a NOT variant of those. RewriteCond %{THE_REQUEST} index
RewriteRule .* ................. [L] GET ../../../../../index?eval{some_malicious_code} HTTP/1.1
Sometimes you might replace that with the literal GET or POST or a NOT variant of those.
In the same way you'd specify ^bar$ in a RewriteRule RegEx pattern to ensure that requests for foobar and barf did not match