views:

25

answers:

1

I have an ajax file that is called when someone begins to type in search bar. I have recently been cleaning up my urls and removing file extentions adding trailing slashes, since then my ajax file doesnt appear to load anymore. can anyone help? here my htaccess so far

Options +FollowSymlinks
Options +Indexes
RewriteEngine on


RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^([^.]+)\.php$ /$1 [R=301,L]
+1  A: 

Assuming that your AJAX requests go to the /includes folder, and your normal pages do not, we can modify your rules a bit so that they look like this (including Cags' comment about the RewriteCond):

Options +FollowSymlinks
Options +Indexes

RewriteEngine on

# We'll do the redirect first, so no other rules get in the way
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^.#?\ ]+)\.php([#?][^\ ]*)?\ HTTP/
# Make sure the request didn't start with "includes"
RewriteCond %1 !^includes/
RewriteRule ^([^.]+)\.php$ /$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ $1.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

I also think that you either wanted /? at the end of the rules in the center block, or /$1/ as the replacement on the rule in the first block, so that the redirect from /page.php to /page gets interpreted correctly after the first redirect (I think right now you'll get redirected twice, once by the first block, and again by the last block).

Tim Stone
great thankyou so much. Works perfect. if you search for something now, you get filtered search results :) http://www.lovelakedistrict.com
AJFMEDIA