You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Wayne Sallee <Wa...@WayneSallee.com> on 2020/02/07 17:48:27 UTC

[users@httpd] RewriteRule Blind to Parent Directories

RewriteRule is Blind to Parent Directories.

So if I have:

<Directory mywebsite.com/dir1/dir2/dir3/dir4/>
RewriteRule (.*) mywebsite.com/dir1/index?$1
</directory>


And the url entered is:
mywebsite.com/dir1/dir2/dir3/dir4/dir5/test

It will get redirected to:
mywebsite.com/dir1/index?dir5/test

Instead of:
mywebsite.com/dir1/index?dir1/dir2/dir3/dir4/dir5/test


Is there a way to use RewriteRule without being blind to parent directories?
I know that I could put this in <Directory mywebsite.com> to make it work.
Can {REQUEST_URI} be fed into RewriteRule to use that as data to be processed?
Like filtering {REQUEST_URI} through (.*)(/dir3)(.*) to redirect to $1$3

Wayne Sallee
Wayne@WayneSallee.com
http://www.WayneSallee.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule Blind to Parent Directories

Posted by Eric Covener <co...@gmail.com>.
On Fri, Feb 7, 2020 at 12:48 PM Wayne Sallee <Wa...@waynesallee.com> wrote:
>
> RewriteRule is Blind to Parent Directories.
>
> So if I have:
>
> <Directory mywebsite.com/dir1/dir2/dir3/dir4/>
> RewriteRule (.*) mywebsite.com/dir1/index?$1
> </directory>
>
>
> And the url entered is:
> mywebsite.com/dir1/dir2/dir3/dir4/dir5/test
>
> It will get redirected to:
> mywebsite.com/dir1/index?dir5/test
>
> Instead of:
> mywebsite.com/dir1/index?dir1/dir2/dir3/dir4/dir5/test
>
>
> Is there a way to use RewriteRule without being blind to parent directories?
> I know that I could put this in <Directory mywebsite.com> to make it work.
> Can {REQUEST_URI} be fed into RewriteRule to use that as data to be processed?
> Like filtering {REQUEST_URI} through (.*)(/dir3)(.*) to redirect to $1$3

I'd avoid <Directory> and relative substitutions if you want it to be intuitive.

Another option is:
https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org