So basically if they come through www.foo.com all of the php pages would be forced to go through the foo php controller. However if they accessed www.foo.co.uk they wouldn’t.
But how do I get it to only do this with php scripts. The reason being is that I have aliased a website. http://www.foobar.com is the main website and http://www.foo.com is the alias.
At the moment the css and js points to “/css/style.css” and “/js/myScript.js”.
I know if I make these links full to my main domain (http://www.foobar.com/css/style.css) it will work but I didn’t really want to do this. Aswell as this all the images would need to be fully linked so that would be a major pain
You’re right, my explanation of the [L] flag was incorrect.
However, I tested your code and what you said also doesn’t seem to be the case
I put that in a .htaccess to test it, and ended up at /baz (used real values instead of the example placeholders of course).
I did some digging, and in the manual it says for the last flag:
Remember, however, that if the RewriteRule generates an internal redirect (which frequently occurs when rewriting in a per-directory context), this will reinject the request and will cause processing to be repeated starting from the first RewriteRule.
It would seem the [L] flag terminates the current rewrite “round”, does an internal redirect which starts a new “round”, and this process is repeated until no more rewrites are done (i.e., input url isn’t changed by any of the rules) or until a certain amount of “rounds” has been gone through (defaults to 10 I read somewhere).
To be honest, the [L] flag always puzzles me a bit. I know I should use it, and I always do, but I’m not 100% sure why.
Ok, what you want to do requires several steps.
First of all, you need a .htaccess file placed in the root of the website.
In this file you first need to tell apache you want to use the rewrite engine:
RewriteEngine On
You then need to tell to apache to do something if the domain is [noparse]www.example.com[/noparse], sort of like “if domain is [noparse]www.example.com[/noparse], do the following”: