picocms / Pico

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

URL rewrite not working (apache rewrite mod active) #577

Closed nderambure closed 3 years ago

nderambure commented 3 years ago

Hello !

I've just installed Pico from composer and set a vhost to see it at http://picocmstest.localdev with mod_rewrite activated, abd vhost configured to allow override all.

If I create a file content/plop.md I get a 404. If I create a content/404.md I get also a 404 but not the one created. Same by creating subfloder with any file in it (including index.md).

Rewrite works perfectly, I've tons of Wordpress in development using the same domain name patern (.localdev) which runs well.

I've also tried to set the Rewritebase to / as indicated in .htaccess, and force url rewrite in config.yml. Also, if I force NO rewrite in config.yml, I still get a 404 for any other page than default one...

I must say, I'm stuck, any idea ? I'm on osx Catalina, Apache 2.4.41.

Thx !

PhrozenByte commented 3 years ago

Do non-rewritten URLs like http://picocmstest.localdev/?plop and http://picocmstest.localdev/?404 work as expected?

Also check your webserver's error.log.

nderambure commented 3 years ago

Thx @PhrozenByte for your quick answer.

No, the ?plop or ?404 urls give me the default 404 page. Nothing in error.log neither...

Another note is that http://picocmstest.localdev/vendor/ give me also the default 404 which adds to the confusion.

PhrozenByte commented 3 years ago

Sounds like something is wrong with your content directory. Check the permissions and make sure that your webserver resp. PHP has read access to your content directory. If your content directory isn't in the default path, use the content_dir config in your config/config.yml.

nderambure commented 3 years ago

After double check, apache and PHP have full access to the content directory, every file in it has 644 and belong to the apache user. If I create an index.md, it does replace the default one, this is the only file that works so far.

Do you know specifically where Pico test or list files in content directory against the requested url ?

nderambure commented 3 years ago

Ok it works when I add content_dir: content in config.yml... So by default, Pico does not look into content dir ? That's weird no ?

I've checked in the function readPages and it get only the sample content directory in vendor/picocms if the config of the content dir is not set.

Note that after setting the content_dir, an index.md must be created in content dir because it does not fallback to the one in sample content dir.

But can you confirm that by default (no config.yml created or no content_dir set), Pico looks only in the sample content ?

Thx again for your help :)

PhrozenByte commented 3 years ago

Pico tries to guess the content dir. However, a root index.md is required for the check to work, otherwise Pico couldn't distinguish it from an empty content dir (which always exists). See https://github.com/picocms/Pico/blob/221625efacb726235ed86ad110472539826a608d/lib/Pico.php#L995-L997

nderambure commented 3 years ago

OK I see, thx for the explanation. I should have created an index.md before creating another file.md and it would have worked then !