Re: mod_rewrite redirect to local path issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/3/11 Steven Bower <dbcmaster@xxxxxxxxx>:
> 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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux