Forum Moderators: phranque
(www\.)?example\.com is more efficient than testing separately for www and non-www. # comment to each code block explaining what it does. It will help you see the logic errors more clearly. [edited by: g1smd at 9:52 pm (utc) on May 13, 2011]
[edited by: tedster at 12:41 pm (utc) on May 18, 2011]
[edit reason] switched to example.com [/edit]
http\:\/\/www\.example\.com\/ should be http://www.example.com/ in the target URL. [edited by: jdMorgan at 7:28 pm (utc) on May 27, 2011]
[edit reason] Example.com [/edit]
[edited by: jdMorgan at 7:31 pm (utc) on May 27, 2011]
[edit reason] Example.com [/edit]
# dotcom to dotcomdotau redirect remove the $ from the pattern so that it can redirect even if there is a port number present on the originally requested URL. #www to http redirect is currently ^www\.example\.com\.au$ and therefore fails to redirect URL requests with a port number. Change that one pattern to be exactly !^(example\.com\.au)?$ here, the ! being "not". DirectoryIndex index.html at the very top of your code. .au/ in one and .au in the other. Always include the trailing slash. The canonical URL is example.com.au/ with a slash. ^/?$ patterns to (.*) and put /$1 on the end of the target URL, on BOTH of the bare domain redirects. example.com/index.html to example.com/ because the ruleset requires tagword/ to be present in the request. Instead,your second rule kicks in and redirects example.com/index.html to example.com/index. To fix this, you can safely delete tagword/ from the condition and the rule of your first ruleset so that it correctly redirects ALL index.html requests. \.html in all patterns to \.html? so that both .html and .htm requests are redirected. .html in the final condition does need to be escaped to \.html. Escape all periods in all RegEx patterns in the condition and the rule. [edited by: jdMorgan at 7:32 pm (utc) on May 27, 2011]
[edit reason] Example.com [/edit]
^[A-Z]{3,9}\ in place of ^[A-Z]+\ in the second ruleset. [^.]+ and where I believe that should be [^/.]+ instead. RewriteCond %{REQUEST_FILENAME}\.html -f as I have long suspected that was either not needed or is incorrect in some way. It slows requests down. You also need DirectoryIndex index.html at the very top of your code.