开发者

Unable to exclude directory from rewriting rules

I tried to do this in many ways, but I really cannot exclu开发者_开发百科de directory "progress" from wordpress rewriting rules in .htaccess. I found many solutions but none of them seems to be working. .htaccess in root directory of wp contains:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress

I tried to use

RewriteCond %{REQUEST_URI} !^/(progress/.*)$

and

RewriteRule ^progress($|/) - [L]

and

RewriteCond %{REQUEST_URI} !^/?(admin|progress)/

and I even tried to put Alias /progress /home/website/progress to httpd.conf but it still not working properly. Surely, mod_rewrite is installed and working, it redirects me to index.php that shows 404 error when I trying to access the directory...


From here.

#Change 
RewriteRule . /index.php [L]

#to:
RewriteRule ./ /index.php [L]


Both of your attempts should work when used correctly. As the rules are tested sequentially, you need to put the exceptional case in front of your existing Wordpress rule:

RewriteRule ^progress($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Or when using the additional condition (well ok, here the order of the conditions does not matter as they all have to be fulfilled):

RewriteCond %{REQUEST_URI} !^/(admin|progress)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


Does the directory progress actually exist? What's inside it?

Where are you placing the code you have provided within the context of the .htaccess?

The line RewriteCond %{REQUEST_FILENAME} !-d will mean the rewrite rule is ignored if the request translates to a real directory.


Instead of following on .htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress

Use the folder name that you want to exclude from wordpress htaccess rule as RewriteBase, so basically try writing following in .htaccess file for the folder "FOLDER_NAME"

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /FOLDER_NAME
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress

And place this .htaccess file into the folder with name "FOLDER_NAME". Please let me know if that works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜