g1smd

msg:4515660 | 8:50 pm on Nov 4, 2012 (gmt 0) |
Please use example.com in this forum so your example URL can be read. Despite this instruction being in the sticky thread at the top of this forum, it is frustrating that only five (5) people have managed to comply with it so far this year.
|
lucy24

msg:4515690 | 12:38 am on Nov 5, 2012 (gmt 0) |
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com [NC] RewriteCond %1 !^(www|ftp|mail)$ [NC] Deep philosophical question here. Or, at least, question about mod_rewrite nuances. Same difference. Apache says: | RewriteCond backreferences: These are backreferences ... which provide access to the grouped parts (again, in parentheses) of the pattern, from the last matched RewriteCond in the current set of conditions |
| Now, technically the last matched Condition is the one that says "the previously captured bit is not (stuff in parentheses)".* So when they say "last matched Condition" do they really mean "last matched positive Condition"? What if the last matched Condition has no parentheses, or only non-capturing parentheses? mod_rewrite is not the place for fuzziness. * You and I know that the parentheses are just there to support the pipes. But mod_rewrite doesn't know that.
|
g1smd

msg:4515692 | 12:49 am on Nov 5, 2012 (gmt 0) |
If the first condition doesn't match, e.g. for all non-www requests, the ruleset doesn't run at all. But that's probably exactly what's wanted anyway.
|
Dinkar

msg:4515762 | 6:05 am on Nov 5, 2012 (gmt 0) |
Why don't you put a separate .htaccess file in your http://www.example.com/vsubdomain folder?
|
lucy24

msg:4515787 | 7:32 am on Nov 5, 2012 (gmt 0) |
| If the first condition doesn't match, e.g. for all non-www requests, the ruleset doesn't run at all. But that's probably exactly what's wanted anyway. |
| I meant the %1 in the Rule. The one in Condition #2 makes perfect sense and doesn't contradict what Apache says. It's the one in the Rule that doesn't seem to fit. | Why don't you put a separate .htaccess file in your http://www.example.com/vsubdomain folder? |
| My impression was that the subdomains don't physically exist, so there's no folder to put an htaccess in.
|
Dinkar

msg:4515809 | 10:18 am on Nov 5, 2012 (gmt 0) |
May be.. but he can create it. I think server will look for .htaccess file in the related folder first and if there is no such file then it will look for same in web root (Please correct me if I am wrong.) So if he create a folder and put a .htaccess file there with simple redirect code then it will be simple solution. Plus less work for the server, as it will find the file in that folder. And that .htaccess file will have just one simple redirect rule so again it saves server from dealing with other rules.
|
lucy24

msg:4515815 | 10:32 am on Nov 5, 2012 (gmt 0) |
You are wrong. Sorry. Once the server learns-- through seeing an Overrides directive in the config file-- that htaccess is a possibility, it will look for an htaccess file in every directory it passes through, from top to bottom. In shared hosting that means: userspace domain root directory physical directories within the root next layer of physical directories and so on until it arrives at the file. Every single one of those might contain an htaccess. In the case of subdomains, the DNS in combination with the server administrator (your host, usually) will point the request toward a particular physical location. It might be the domain root directory, or it might be a subdirectory. But the request doesn't teleport straight to its destination. It has to pass through all the surrounding directories, starting with the config file. It's like a human going to an office on the 2nd floor of a building. You can't just zip up the fire escape and climb in the window even if you know exactly where it is. You have to get past the security guard in the lobby, and the one outside the elevators, and the receptionist outside your target office. And it's no use telling the downstairs guard that the upstairs receptionist knows you. If you don't have the right credentials, you'll never get that far.
|
Dinkar

msg:4515893 | 3:24 pm on Nov 5, 2012 (gmt 0) |
Thank you lucy for correcting me. Now I know that it inherit the parent file. Isn't there any way to tell the server that it shouldn't inherit the parent file?
|
lucy24

msg:4515929 | 5:18 pm on Nov 5, 2012 (gmt 0) |
No. Inheritance is an Apache absolute. It always works from top to bottom. One of the few things that isn't inherited is the RewriteEngine; that has to be turned on separately in each htaccess that uses it.
|
|