Avoiding Wordpress .htaccess rules on specific fol

2019-09-11 03:27发布

问题:

I have Wordpress installed in root and a particular folder not related to Wordpress. I created a .htaccess file for the particular folder, but it is not working. The Wordpress .htaccess is always been called.

Wordpress .htaccess:

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

Particular folder .htaccess:

//301 Redirect Old File
Redirect 301 http://www.domain.com/folder/start.php http://www.domain.com/folder/index.php

When I load the above old address (that does not exists), the Wordpress .htaccess is called, instead of use the folder's .htaccess to redirect.

回答1:

You don't need multiple .htaccess you can put all the rules on the WordPress main .htaccess:

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

Use either:

RewriteRule ^folder/start\.php$ /folder/index.php [R=301,L,NC]

Or

Redirect 301 /folder/start.php http://www.domain.com/folder/index.php

Don't forget to change folder to your actual folder name.