简体   繁体   中英

Htaccess how to not redirect to root if in specific directory

I have the following code in my htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !_assets/ajax
RewriteRule !^index\.php$ index.php [L]

I thought and hoped this would exclude the _assets directory from being redirected to the root, but without success.

All directories are being redirected to the root, where I explode the URI to get the respective pages (in PHP). The htaccess file is actualy working as the right content is being displayed, according to the uri.

So to be briefly, my ajax calls do not work because of this.

How can can I make this work?

I'm using WAMP and created a virtual host named http://project.localhost .

The easiest way to handle this is with a simple rewrite rule that you put before any other rewrite rules.

RewriteRule ^/_assets/ajax/ - [L]

It say to take every URL that matches the regex ^/_assets/ajax/ (that is, everything in that directory), don't rewrite it, and stop processing the .htaccess file.

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