httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apt...@spam-message.com
Subject [users@httpd] Redirection
Date Tue, 18 Oct 2011 17:30:20 GMT
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message