picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.83k stars 617 forks source link

url rewriting not working - pico 1.0 #400

Closed clausbertels closed 6 years ago

clausbertels commented 6 years ago

I can't seem to get clean urls.

I'm using Apache and have the mod_rewrite module loaded. Now my URL's look like "site.dev/?subfolder/page" and "site.dev/?aboutme".

Forcing the rewrite in config strangely fixes the twig variables — {{page.url}} — to "site.dev/subfolder/page" and "site.dev/aboutme". But when I copy and enter those urls in my browser I get a server 404. The urls with the questionmarks still work, though.

I tried adding R=301 flags to both RewriteRules in the .htaccess file with no success.

What am I missing?

PhrozenByte commented 6 years ago

Apache's mod_rewrite module is likely not enabled.

First of all, make sure that you've actually uploaded Pico's .htaccess file to your server - it's a hidden file and is often left behind. Furthermore, make sure that the file is actually named .htaccess on your server, not htaccess, htaccess.txt or anything else.

Try removing the <IfModule mod_rewrite.c> and the matching </IfModule>. If you get a 500 Internal Server Error, you can be sure that mod_rewrite isn't set up correctly. Check Apache's error.log for the error message. It likely tells you one of the following:

  1. Apache's mod_rewrite module isn't enabled/loaded. Ask your server administrator how to enable/load mod_rewrite (e.g. on Debian/Ubuntu you'll have to run sudo a2enmod rewrite and sudo service apache2 reload).
  2. You're not allowed to use mod_rewrite in a .htaccess file. Make sure AllowOverride FileInfo (or AllowOverride All) is set in your virtual host config file.

If you don't get a 500 Internal Server Error, try accessing http://example.com/pico/CHANGELOG.md - you should see Pico's 404 page (if you rather see Apache's 404 page, make sure the CHANGELOG.md file exists). If you rather see the contents of the CHANGELOG.md, you can again be sure that mod_rewrite isn't set up correctly. Again, check Apache's error.log for the error message.

clausbertels commented 6 years ago

I'm developing locally. I had the mod_rewrite enabled.

But I had set the AllowOverride to all in the vhosts config file, but not in the httpd config file. It was still set to none over there. Setting it to all fixed the issue.

Thank you for the quick reply and for maintaining my favourite cms.