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.

In cPanel’s addon domains there is also a redirect entry: http://asiandivingvacation.com/$1

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.

  • Digg
  • del.icio.us
  • blogmarks
  • Reddit
  • Simpy
  • StumbleUpon
  • Technorati
  • description
  • Ma.gnolia
  • Slashdot
  • Sphinn
  • Spurl

Related Posts

Sponsored links

Gabbeh
Branson Missouri

Tags: , , ,

Posts linking to this article:

Re: friendly urls and htaccess
Try this http://www.prodevtips.com/2008/08/03/modx-htaccess-problems-and-solutions/

Re: .htacess et configuration pour urls simple
J'ai trouve un truc qui a l'air de fonctionner.... mais c'est a voir avecmon second probleme... ICI http://modxcms.com/forums/index.php/topic,30203.0.html qui a mon humble avis en découle Le truc qui a marché pour moi ...

Subscribe with Google Reader