Search code examples
ajax.htaccessmod-rewritehttp-redirectconcrete5

mod_rewrite .htaccess on AJAX calls throwing errors


I'm developing a new site for a church. The old domain is: chippingcampdenbaptistchurch.org.uk The new domain is: campdenbaptist.org.uk

The campdenbaptist.org.uk domain is an addon domain to a Linux shared server. Inside it's folder it has the following .htaccess file:

RewriteEngine On
RewriteRule !^(dev(/.*)?|www\.chippingcampdenbaptistchurch\.org\.uk)$ http://www.chippingcampdenbaptistchurch.org.uk/ [R,L]

Basically, if the user is asking for JUST campdenbaptist.org.uk then they will get sent to the old site (living on a different server at www.chippingcampdenbaptistchurch.org.uk). BUT if they are asking for campdenbaptist.org.uk/dev - then they are sent into the /dev folder where the new site lives.

It runs on Concrete5 (http://www.concrete5.org/) and the .htaccess inside this /dev folder looks like this:

SetEnv TZ Europe/London

<IfModule mod_rewrite.c>

RewriteEngine On

#=============WWW. REDIRECT===========#
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/dev/$1 [R=301,L]

#=============C5 REDIRECT===========#
RewriteBase /dev/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]

</IfModule>

It basically checks to see if the www. is there (and if not, append it) And deals with the Pretty URLs in the 'C5 redirect' block.

The issue I'm having is that sometimes the server seems to throw errors (redirects to old site) for AJAX calls, such as the following two:

http://www.campdenbaptist.org.uk/dev/tools/blocks/booking_form/snag_dates.php?1=1&date=03/16/2013&page=272

(if you change 1=1 in the first part of the query string to something like a=1 it seems fine?!) - or

http://www.campdenbaptist.org.uk/dev/tools/required/files/importers/remote?_returntype=text&fIDW&task=update_file&url_upload_1=http%3A%2F%2Ffeatherfiles.aviary.com%2F2012-11-26%2F1d6b111bd5684978a293e193828a181a.jpg&ccm_token53952089%3A5ec7e1b4c88c7e62ba9f5da66b36cef0

Any ideas? It seems to be that if you remove the query strings from both of the above calls the error doesn't occur. Thanks very much!


Solution

  • Annoyingly, it was a mod_sec error caused by the hosting provider. 1=1 is now fixed, and they're currently working on the .aviary.com problem. Thanks anyway!