Re: Issue with trailing slashes after rewrite

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

 



It seems like I've managed to make it work like I wanted using this rule:

* * *

# Turn rewrite engine on
RewriteEngine On

# Fix missing trailing slashes for foo.mydomain.com
RewriteCond %{HTTP_HOST} ^foo\.mydomain\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/foo%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

# Change DocumentRoot for foo.mydomain.com
RewriteCond %{HTTP_HOST} ^foo\.mydomain\.com$
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule .* /foo%{REQUEST_URI}  [QSA,L]

* * *

Thanks everyone for your help.

On Sun, Mar 18, 2012 at 11:36 PM, Nala Gnirut <nala.gnirut@xxxxxxxxx> wrote:
On Sun, Mar 18, 2012 at 11:16 PM, Eric Covener <covener@xxxxxxxxx> wrote:
The P flag is explicitly used to proxy. If you want to redirect,
substitute a full URL and use the R flag instead.

I need to dynamically change DocumentRoot for some subdomains pointing to the same local path.

This rule works (almost) as expected, but has an issue with links to subfolders without trailing slash:

RewriteCond %{HTTP_HOST} ^foo\.domain\.com$

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule .* /foo%{REQUEST_URI}  [QSA,L]

That is

http://foo.domain.com/bar/ works, while

http://foo.domain.com/bar is redirected to a wrong local path (/foo/foo/bar instead of /foo/bar)


[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