简体   繁体   中英

rewritecond exclude url in .htaccess

I have these working rewrite rules :

# Allow access to assets folder from plugins folders
RewriteRule ^app/plugins/(.+)/assets - [L]

# forbid access to files and folders under app
RewriteRule ^app/.*$ - [L,F]

# rewrite to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?action=$1 [L,QSA]

Now I would like to exclude from these rules everything located under http://www.mywebsite.com/wordpress/ ... Therefore I've added a new rewrite condition :

...
# rewrite to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^\/wordpress\/ [NC]
RewriteRule ^(.*)$ index.php?action=$1 [L,QSA]

But it dosen't work. When I try to access something like this : http://www.mywebsite.com/wordpress/contact-us/

it redirects me to index.php...

Any help would be really appreciated.

Ok I finally found what was going wrong with all of this : In fact I did not notice that a .htaccess file was present in my /wordpress directory. So on the .htaccess of my root directory I've added this rule on top of all the others :

RewriteRule ^wordpress - [L]

Then in the .htaccess of the wordpress directory I've these rules :

RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]

I don't know if everything is optimized but it works !

Try this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/wordpress/ [NC]
RewriteRule ^(.*)$ index.php?action=$1 [L,QSA]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM