Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Htaccess Redirecting Questions


lucy24 - 2:26 am on Jan 25, 2013 (gmt 0)


It might help if I understood what "psp" means.* Do you want all your subdomains to redirect to the same file, or will there be a separate one for each subdomain?

Either way, the body of the rule will have the pattern

^(index\.html)?$

because you're grabbing two groups of requests: the ones who ask for "index.html" by name, and the ones who ask for the index page by its proper name, i.e. nothing. So the body of the rule will look at requests for "exactly index.html or exactly nothing".

Unlike your normal index-file redirect, this will have to come before the other named-file redirects, because "index.html" is a subgroup of "blahblah.html". And also unlike the normal index redirect, you will not need to look at THE_REQUEST, because there won't be any internal requests for this file. Instead the Conditions will look at the HTTP_HOST and pull out all the requests for subdomains-- either all of them collectively, or one at a time.

Do you have a whole lot of subdomains, or a fairly short finite list? In general, rules will run a lot more efficiently if you can tell them the exact text to look for:

(one|two|three|four)

rather than

\w+ or [a-z]+ or [^/.]+


* Memo to self: create macro for "It might help if I understood what X means".


Thread source:: http://www.webmasterworld.com/apache/4537934.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com