Intro
- This is a note to fellow newbies who’ve experienced the same issue.
- I believe I’ve solved my problem (see also ’Final Notes’) but I’ve posted as it may help others.
- Tags: friendly URLS, .htaccess, httpd.conf, 404 error, Windows XP
Quick Scenario
- Friendly URLs doesn’t work. I’ve followed every step but still get 404 error.
Quick Solution
- Ensure you’ve changed "AllowOverride None" to "AllowOverride All" in EVERY instance in your Apache httpd.conf file.
- Why 404 error? Because Apache is more than likely NOT parsing your MODx .htaccess file.
Hope this helps.
In-depth (for those interested)...
Scenario
- I’ve enabled Friendly URLs in MODx settings (via management console), and I’ve changed "AllowOverride None" to "AllowOverride all" between the <Directory /> and </Directory> markers in the Apache httpd.conf file, and I’ve followed the instructions (e.g.
http://wiki.modxcms.com/index.php/Friendly_URLs_Guide) to modify my .htaccess file for re-writing conditions.
- I’ve done all these things, but I still receive a 404 Error when navigating to http://localhost:8080/testingmodx/modx-2.0.4-pl2/testingalias.
- Note: your URL will of course be different: you may using 127.0.0.1 instead of localhost, your port may be the default 80, and your MODx install path may be c:\apache-X.Y.Z\htdocs\modx.
What to do?
1. Try typing random nonsense in your .htaccess file, e.g. "aaoijfafwe452452", and testing that Apache is parsing your .htaccess file:
1.1 Done, now I get an "Internal Server Error".
1.1.1 Ok, Apache IS parsing your .htaccess file but your RewriteCond statements must not be functioning correctly. Did you follow the instructions correctly? Go back and make sure you do, then try again.
1.2 Done, but I still get the 404 error.
1.2.1 Ok, Apache is NOT parsing your .htaccess file. Open your Apache httpd.conf file again and search for "AllowOverride None". Yes yes, you have already changed it once, but did you change BOTH instances? Change the second one also to "AllowOverride all". 1.2.2 Now go back to "What to do" 1. and try the random nonsense to ensure parsing.
1.2.3 Or, skip 1.2.2, remove any nonsense from your .htaccess file, save it, and try your Friendly URL once again.
1.2.4 You should now see your page correctly
Final Notes
- The instructions I followed (see
http://wiki.modxcms.com/index.php/Friendly_URLs_Guide) did mention the other instances of "AllowOverride None" but it did not explicitly advise to change each one, hence I originally changed ONLY the primary instance (between <Directory... etc.).
- Perhaps more knowledgeable members can comment on whether this solution is best practice, or whether it just happens to work and creates other issue(s).
- Please remember to restart Apache if you change the httpd.conf file.
P.s.
- Windows XP SP3
- Apache 2.2
- PHP 5.3.3
- MODx Revolution 2.0.4
- Developed on localhost / 127.0.0.1
Regards