ebabis ebabis - 5 months ago 12
Ajax Question

How to exclude ajax from htaccess?

I'm trying to force trailling slash in my site. I have found the bellow code that it works but it causes problem with ajax code.

This is my htaccess code

RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]


So now I want to exclude the ajax from this or I if we can exclude a specific url that uses ajax.

e.g.
my-site.com/onepage

Answer

To exclude /onepage you can use a negitive RewriteCond :

RewriteCond %{REQUEST_URI} !/onepage
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]