MODx htaccess problems and solutions
Yesterday I discovered that the flash banner wouldn’t load on www.asiandivingvacation.com, I suppose the crossdomain xml didn’t work like I expected it to.
Instead of messing around trying to make the crossdomain stuff work in Flash, I decided to just do a redirect like I have to do anyway and the problem would be solved. No one would be able to access the site through the www version anymore.
So I logged into cPanel and did the redirect, however when I loaded the page Apache complains that there is a never ending redirection loop in place and refuses to load it, great. I checked the redirection list in order to delete it and my new redirect is not there! So I opened a support ticket where I described the problem, this morning I got the answer from A2’s excellent support:
Hello,
It looks like there was an error in your .htaccess file, I have corrected the error and it now appears to be working as expected.
Thank you!
==============================================
Gerald Stuhrberg
And the page loads properly again. Gerald, I’m the one who should thank you for cleaning up my mess!
We still have to go to the bottom of this, here is the relevant lines in the .htaccess file that worked before I started redirecting in cPanel:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /asd
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
Note the /asd part, originally I tried with just / which worked on localhost, but not A2.
Here is Gerald’s new version:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
RewriteCond %{HTTP_HOST} ^www.asiandivingvacation.com$
RewriteRule ^/?(.*)$ "http\:\/\/asiandivingvacation\.com\/$1" [R=301,L]
Notice the two extra lines at the end combined with the original RewriteBase /. To be honest, Apache access files feels like a jungle, I can’t really explain 100% why this works so I’ll refrain. But at the moment it does with my MODx install, using pretty URLs and everything.
Update: I’m using MODx for a project at work at the moment on a staging server that are riddled with symlinks. Commenting out Options +FollowSymlinks takes care of things though. It looks like this at the moment:
RewriteEngine On
RewriteBase /online/project_x
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
In this case online is in the www folder.
Related Posts
Tags: a2 hosting, apache, htaccess, MODx

















Add New Comment
Viewing 2 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks