I need to rewrite to another host, unless the url starts with /store or /utils
I have tried looking at the apache docs, but I can't work out how to do this
|
I need to rewrite to another host, unless the url starts with /store or /utils I have tried looking at the apache docs, but I can't work out how to do this
| |||
|
feedback
|
|
Ok assuming you want to redirect to a host otherhost.example.com this should do the trick under Apache.
The conditional part says "if the request URI doesn't begin with /store/ or /utils/ apply the Rewrite. The rewrite rule will then generate a 301 redirect with the captured URI appended to the request. | |||||
|
feedback
|
|
As ickymettle succintly responded, the ! flag signifies it should consider the input as matched if the conditions of the rule are NOT met. So, breaking down the syntax:
The AddedBytes.com mod_rewrite cheatsheet is dead handy, I have it taped to the wall next to where I sit (as I dive into htaccesses almost daily and desperately try to teach myself mod_rewrite voodoo!) There's also a [great detailed article on PerishablePress with loads of tips, tricks etc. The one nice thing about mod_rewrite is that it isn't deprecated with new releases constantly, so old articles on the topic remain perfectly valid :-) Might as well go for broke and also mention [the mod_rewrite / .htaccess cheatsheet on TheJackol, which has some useful quick code snippets and a few bits of info. Other URLs:
Sorry I couldn't hyperlink them, I don't have 10 Rep points yet so the system blocked me from hyperlinking all three :-( | |||
|
feedback
|
Note: This is the syntax for ISAPI_Rewrite, which should be compatible with mod-rewrite. | |||
|
feedback
|