httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Ionescu <bobsie...@googlemail.com>
Subject Re: [users@httpd] mod_rewrite redirect to local path issue
Date Wed, 11 Mar 2009 23:27:42 GMT
2009/3/11 Steven Bower <dbcmaster@gmail.com>:
> Hi-
> I am using mod_rewrite to redirect from a sub-directory of my existing
> domain to a new domain just for this section.
> Here is my .htaccess file in /othersite/ (specific domains and paths
> hidden):
> <IfModule mod_rewrite.c>
>     RewriteEngine on
>     RewriteBase /othersite/
>     RewriteRule ^(.*)$ http://<myotherwebsite>.com/$1 [R=301,L]
> </IfModule>
> When I go to <mycurrentwebsite>.com/othersite/ (or any file within this
> directory) it redirects perfectly fine. The strange part is when I go to
> <mycurrentwebsite>.com/othersite (with no trailing slash), I get redirected
> to <myotherwebsite>.com//var/www/<mycurrentsite>.com/web/othersite/. Apache
> for some reason replaces the $1 with the local path, which is a major
> security issue. I would rather not have my server paths revealed in this
> way.
[...]
> I am running Apache Version 2.0.52 on CentOS 4.6

IIRC this issue is fixed in the 2.2 branch.

Workaround: Put the rules into /.htaccess instead of /othersite/.htaccess with

    RewriteEngine on
    RewriteBase /
    RewriteRule ^othersite/?(.*)$ http://<myotherwebsite>.com/$1 [R=301,L]

But anyway: Unless you're using other RewriteRules which may conflict
with the Redirect directives provided by mod_alias, use mod_alias for
such a simple redirection instead of mod_rewrite:

Redirect 301 /othersite http://<myotherwebsite>.com

Bob

---------------------------------------------------------------------
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