| 8:41 pm on May 15, 2003 (gmt 0)|
Doh! Forgot to mention the point is to keep people and bots out of the physical directory "/catalog/" and in the root ones [test.com...] [test.com...] etc.
| 8:58 pm on May 15, 2003 (gmt 0)|
Check out this thread for self-help: Introduction to mod_rewrite [webmasterworld.com]
If this doesn't help you, please give a few examples of the requested URL and what URL you want that request redirected to. Please include everything, including "http://mydomain.com" in both, just to be clear.
Also, do you use query strings?
I suspect your solution is an easy one, but as always, defining the problem thoroughly is the hard part.
| 9:48 pm on May 15, 2003 (gmt 0)|
site.com/dog rewrites from actual file site.com/catalog/dog
site.com/cat rewrites from actual file site.com/catalog/cat
site.com/cow rewrites from actual file site.com/catalog/cow
Extra desired behavior:
site.com/catalog/[anything] redirect to site.com/
| 10:47 pm on May 15, 2003 (gmt 0)|
OK, as I understand it, you wish to accomplish three things:
- Redirect external requests for [site.com...] to [site.com...]
- Redirect external requests for [site.com...] to htpp://site.com/cat/ (Add a trailing slash, basically)
- Serve files from the catalog/cat subdirectory in response to external requests for the [site.com...] files.
If so, this should work. The first two are external 301 redirects, and the last one is an internal redirect. That is important, and the order of the last two rules is also important to prevent a loop.
RewriteRule ^catalog http://www.site.com/ [R=301,L]
RewriteRule ^(cat¦dog¦cow)$ http://www.site.com/$1/ [R=301,L]
RewriteRule ^(cat¦dog¦cow)/(.*)$ /catalog/$1/$2 [L]
Remember to replace the broken vertical pipe "¦" characters with the solid ones from your keyboard.
| 2:47 pm on May 16, 2003 (gmt 0)|
Thanks for the suggestion Jim.
The infinite loop problem is fixed, but now all requests for /cat, /dog, /cow or /catalog* are getting redirected to the root.
I swear I've seen to weird stuff like this before, like applying redirect rules to server side include paths.
| 3:19 pm on May 16, 2003 (gmt 0)|
> /catalog* are getting redirected to the root.
This redirect for /catalog is happening because of requirement number one, implemented in RewriteRule number 1. If the requirement is wrong, the Rule will be wrong, and it sounds like it is.
You can redirect anything that starts with catalog - including catalog followed by nothing, or anything that starts with catalog followed by a slash and anything else (including blank), or you can require that catalog/ be followed by another subdirectory and a slash - whatever you want. But the regular expressions used in mod_rewrite require that you be absolutely specific as to what you want rewritten and what you don't.
The redirects of cat¦dog¦cow may be taking place for the same reason - that the requirements are incorrect, so the Rule is incorrect. Or, they can be taking place because some down-stream .htaccess or script is doing another external (i.e. 301 or 302) redirect; In which case, the whole .htaccess file gets processed again. Take a look at your set-up and see if that might be the case. This could also be some weirdness in the server set-up (The SSI-include redirect thing sounds fishy to me).
| 4:50 pm on May 22, 2003 (gmt 0)|
This rule below sends the file "real.html" in response to requests for "virtual.html".
RewriteRule ^virtual.html$ real.html [L]
How do I redirect requests for "real.html" to "virtual"? All the .htaccess attempts I've tried result in loops.