English 中文(简体)
.htaccess RewriteOptions Inherit is not inheriting
原标题:

I ve been trying inerhiting my rules with RewriteOptions Inerhit, because for some reason rules are not inerhited by default.You might want to know that I m on a LiteSpeed server.

The IP XXX.XX.XX.XX points to a subdomain which is located in ~/public_html/dir/sub/

This .htaccess is located in ~/public_html/:

RewriteEngine On
RewriteOptions Inherit

RewriteCond %{HTTP_HOST} ^XXX.XX.XX.XX$ [NC]
RewriteRule ^(.*)$ http://www.example.com [R=301,L]

In ~/public_html/dir/ I have this .htaccess:

RewriteEngine On
RewriteOptions Inherit

And in ~/public_html/dir/sub/ the .htaccess also looks like this:

RewriteEngine On
RewriteOptions Inherit

In this .htaccess there s also some WordPress code below which I also tried to remove but nothing changed.

I also tried to use RewriteOptions Inherit Before but rules from ~/public_html/ are not applied. So if I go to the IP I m not redirected.

Anyone faced such a problem before and got any tips for me what I cloud try? I really did a lot of search but couldn t figure out what s wrong.

最佳回答

I found out that inherited (in root folder) rules are parsed with the subdirectory context

/.htaccess
RewriteRule melon http://www.google.com [R,L]
RewriteRule /services/bar http://www.yahoo.com [R,L]

/services/.htaccess
RewriteEngine On
RewriteOptions Inherit
deny from all

http://mydomin.com/services/bar => 403
http://mydomin.com/services/melon => google.com !!!

Maybe try with a more loose RewriteRule (.*)

Also, as RewriteRule context is lost, try using RewriteCond capture pattern if you need conditionnal rewrite

RewriteCond %{REQUEST_URI} (/services/.*)
RewriteRule (.*) http://elsewhere.com/%1 
#in place of a basic RewriteRule /services/(.*) http://elsewhere.com/$1 
问题回答

暂无回答




相关问题
Ignore symlinks in clean URL s in .htaccess

Example URL: example.com/user /user is both a symlinked directory and a valid URL to content on my site. I user Horde Routes to request the content and all requests to the site go through index.php. ...

.htaccess File Options -Indexes on Subdirectories

I have the following .htaccess line, simple no indexes on root. Options -Indexes What do we add so it propagates to any sub directory instead of having to create one file for each? One .htaccess on ...

Mod Rewrite ignoring -d

After a day or two, I am still fighting with Mod Rewrite. It seems that 60% of my development time is spent battling the server. My current URL structure is such that all http://example.com/xyz and ...

ErrorDocument 404 Not Sending Referrer Information: PHP

I m using a standard htaccess ErrorDocument 404 to redirect users to a new page. In order to customize the 404, I need to know their referrer information (from the page they Tried to visit). $...

Find all htaccess files on server [closed]

I m looking for a Linux command to go through all the directories on my server and find all .htaccess files. The output would be a list of all those files with full path, creation/modification date ...

301 Redirect Help with Dynamic URL s and Multiple Id s

I just did a redesign for www.wildchildclothes.com which has a new URL structure. The old site ran on Zen Cart and had a bad URL structure. Here are some examples of what I want to redirect from: OLD:...

热门标签