On 10/18/2011 01:30 PM, aptach@xxxxxxxxxxxxxxxx wrote:
I've spent at least three hours trying to do what seems like a simple redirection. Yes, I've read documentation, searched the Google god and read numerous articles and posts, etc. In a nut shell, it seems when I add a leading slash to the pattern of a redirect, it breaks. If I add a leading path (with or without a leading slash) to the pattern things break. Ultimately, here's what I'm trying to do... I have an old, outdated document. For simplicity, let's say the old document is: mydomain.com/j15/me.html I want "http://mydomain.com/j15/me.html" to be redirected to "http://mydomain.com/them.html". Sounds simple enough. As a test, I started even simpler. I tried to redirect "http://mydomain/me.html" to ""http://mydomain/them.html" with both files being in the root directory. Of course, I only used one redirect at a time, but here's the list of different redirects that worked: # ------ # me.html redirects, as expected: RewriteRule me\.html them.html RewriteRule ^me\.html$ them.html # in the next 2... # anythingme.html redirects, as expected: RewriteRule me\.html$ them.html RewriteRule ^.*me\.html$ them.html # ------ Generally, redirects (Rewrite module) and regular expressions seem to be working. Next, I tried adding a leading slash to the pattern, which all the documentation says should work. Still keeping it simple, and in root of the server, I tried the following with "http://mydomain/me.html" and all resulted in a 404: RewriteRule /me\.html them.html RewriteRule /me\.html$ them.html RewriteRule ^/me\.html$ them.html RewriteRule [any_of_above] http://mydomain/them.html # just for grins, I tried escaping the slash: RewriteRule ^\/me\.html$ them.html # ------ I can specify a path in the redirected URI, for example I can redirect me.html from the root to a subdirectory (path): RewriteRule me\.html /somepath/them.html Any ideas why a leading slash, or a leading path, in the pattern breaks things? Thanks, -- Terry -- --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See<URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
Terry,The leading slash won't match in the per-directory context (htaccess, directory, location).
Frank --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx