Hi Adam!
There should be NO difference between Apache 2.x versions. However, I suspect that there may be something in the VirtualHost setup which is different between your hosted and home servers (the location of the DocumentRoot in each - but I didn't see anything like that below) OR there may be something that the WinDoze version doesn't like (but I didn't see anything in this regard).
Argh! I don't like going through masses of code (especially using {THE_REQUEST}) but, since the problem is with the admin redirections ...
Code:
Options +FollowSymLinks
Options -Indexes
RewriteEngine On
RewriteRule ^confirm/(\d+)?/(\w+)/?$ confirm_user.php?userID=$1&hash=$2 [L]
RewriteCond %{THE_REQUEST} confirm_user\.php
RewriteRule ^confirm_user\.php - [F]
RewriteRule ^forgotpassword/?$ forgot_pass.php [L]
RewriteCond %{THE_REQUEST} forgot_pass\.php
RewriteRule ^forgot_pass\.php - [F]
RewriteRule ^recoverpassword/(\d+)?/(\w+)/?$ recover_pass.php?userID=$1&hash=$2 [L]
RewriteCond %{THE_REQUEST} recover_pass\.php
RewriteRule ^recover_pass\.php - [F]
RewriteRule ^book/([A-Za-z0-9]+)/(([0-9][0-9][0-9][0-9])-([0-1][0-9])-([0-3][0-9]))/([A-Za-z0-9]+)/?$ book.php?roomID=$1&date=$2&period=$6 [L]
RewriteCond %{THE_REQUEST} book\.php
RewriteRule ^book\.php - [F]
RewriteRule ^bookings(/(\w+))?(/(\d+))?/?$ bookings.php?type=$2&id=$4 [L]
RewriteCond %{THE_REQUEST} bookings\.php
RewriteRule ^bookings\.php - [F]
RewriteRule ^availability(/([^/]+))?(/([^/]+))?(/([^/]+))?/?$ availability.php?week=$2&year=$4&tab=$6 [L]
RewriteCond %{THE_REQUEST} availability\.php
RewriteRule ^availability\.php - [F]
RewriteRule ^facilities/?$ facilities.php [L]
RewriteCond %{THE_REQUEST} facilities\.php
RewriteRule ^facilities\.php - [F]
RewriteRule ^preferences/?$ preferences.php [L]
RewriteCond %{THE_REQUEST} preferences\.php
RewriteRule ^perefences\.php - [F]
RewriteRule ^admin/?$ admin.php [L]
Almost invariably, the use of an optional trailing slash will cause problems - and it will certainly not match the next mod_rewrite block as you're dealing with {THE_REQUEST} which does not change with the {REQUEST_URI} changes made by mod_rewrite
RewriteCond %{THE_REQUEST} admin\.php
RewriteRule ^admin\.php - [F]
RewriteRule ^admin/users(/(\w+)?/(\d+))?/?$ admin_users.php?action=$2&userID=$3 [L]
This should NEVER match as you've redirected admin/? above to admin.php.
RewriteCond %{THE_REQUEST} admin_users\.php
RewriteRule ^admin_users\.php - [F]
Ditto
RewriteRule ^admin/notes/?$ admin_notes.php [L]
[indent]et al ... Sorry, I gave up here.[indent]
RewriteCond %{THE_REQUEST} admin_notes\.php
RewriteRule ^admin_notes\.php - [F]
RewriteRule ^admin/terms(/(\w+)?/(\w+)?/(\d+))?/?$ admin_terms.php?type=$2&action=$3&ID=$4 [L]
RewriteCond %{THE_REQUEST} admin_terms\.php
RewriteRule ^admin_terms\.php - [F]
RewriteRule ^admin/periods(/(\w+)?/(\d+))?/?$ admin_periods.php?action=$2&periodID=$3 [L]
RewriteCond %{THE_REQUEST} admin_periods\.php
RewriteRule ^admin_periods\.php - [F]
RewriteRule ^admin/rooms/?$ admin_rooms.php [L]
RewriteCond %{THE_REQUEST} admin_rooms\.php
RewriteRule ^admin_rooms\.php - [F]
RewriteRule ^admin/backup(/([0-9]+))?/?$ admin_backup.php?backup=$2 [L]
RewriteCond %{THE_REQUEST} admin_backup\.php
RewriteRule ^admin_backup\.php - [F]
RewriteRule ^admin/logs(/([a-z]+))?(/([0-9]+))?/?$ admin_logs.php?method=$2&id=$4 [L]
RewriteCond %{THE_REQUEST} admin_logs\.php
RewriteRule ^admin_logs\.php - [F]
RewriteRule ^admin/settings/?$ admin_settings.php [L]
RewriteCond %{THE_REQUEST} admin_settings\.php
RewriteRule ^admin_settings\.php - [F]
RewriteRule ^login/?$ login.php [L]
RewriteCond %{THE_REQUEST} login\.php
RewriteRule ^login\.php - [F]
RewriteRule ^privacy/?$ privacy.php [L]
RewriteCond %{THE_REQUEST} privacy\.php
RewriteRule ^privacy\.php - [F]
RewriteRule ^logout/?$ login.php?action=logout [L]
RewriteRule ^ajax/?$ ajax_wrapper.php [L]
RewriteCond %{THE_REQUEST} ajax_wrapper\.php
RewriteRule ^ajax_wrapper\.php - [F]
RewriteRule ^help/?$ help.php [L]
RewriteCond %{THE_REQUEST} help\.php
RewriteRule ^help\.php - [F]
RewriteCond %{THE_REQUEST} ajax\.php
RewriteRule ^ajax\.php - [F]
RewriteCond %{THE_REQUEST} cron\.php
RewriteRule ^cron\.php - [F]
RewriteRule ^api/?$ api.php [L]
RewriteCond %{THE_REQUEST} api\.php
RewriteRule ^api\.php - [F]
#RewriteRule ^api/docs/?$ api_docs.php [L]
#RewriteCond %{THE_REQUEST} api_docs\.php
#RewriteRule ^api_docs\.php - [F]
#RewriteRule ^api/get/bookings/?$ bookings.xml [L]
#RewriteCond %{THE_REQUEST} bookings\.xml
#RewriteRule ^bookings\.xml - [F]
#RewriteRule ^api/get/today/?$ today.xml [L]
#RewriteCond %{THE_REQUEST} today\.xml
#RewriteRule ^today\.xml - [F]
#RewriteRule ^api/post/book/?$ api_post.php [L]
#RewriteCond %{THE_REQUEST} api_post\.php
#RewriteRule ^api_post\.php - [F]
RewriteRule ^error/401?$ 401.php [L]
RewriteCond %{THE_REQUEST} 401\.php
RewriteRule ^401\.php - [F]
RewriteRule ^error/404?$ 404.php [L]
RewriteCond %{THE_REQUEST} 404\.php
RewriteRule ^404\.php - [F]
RewriteRule ^error/403?$ 403.php [L]
RewriteCond %{THE_REQUEST} 403\.php
RewriteRule ^403\.php - [F]
RewriteRule ^error/500?$ 500.php [L]
RewriteCond %{THE_REQUEST} 500\.php
RewriteRule ^500\.php - [F]
ErrorDocument 401 /error/401
ErrorDocument 404 /error/404
ErrorDocument 403 /error/403
ErrorDocument 500 /error/500
I would have thought that the [F] needed the Last flag to terminate those block statements but, "if it ain't broke, don't fix it!"
Now, using {THE_REQUEST} (e.g., "GET /index.html HTTP/1.1") is a terrible way to go as you must parse the middle of the string to find the initial file requested (and has NOTHING to do with the result of a redirection (i.e., {REQUEST_URI}). Moreover, having these {THE_REQUEST} variables interleaved with {REQUEST_URI} (RewriteRules can ONLY attempt to match the {REQUEST_URI} string) is horribly confusing!
Tip:
Group the core directives (Options, ErrorDocument and Redirect statements) first then get into the mod_rewrite. When dealing with mod_rewrite, order by the most specific rules first then go to the more generic (being sure not to undo the earlier redirections unintentionally).
Regards,
DK
Bookmarks