picocms / Pico

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

Pico sub pages throws a Not Found error. #555

Closed notakoder closed 3 years ago

notakoder commented 3 years ago

Had a system failure and reinstalled my OS, Apache and PHP. I have since changed the Apache document root from /var/www/html to /var/www/. Module rewrite is already enabled. All my projects folders have 755 permission and the browser lists them all under localhost. The projects show their home pages and I can navigate to sub pages in them which are mostly pure HTML and PHP pages. I can access the home page of Pico projects, however, navigating to other pages throws the following error.

Not Found

The requested URL was not found on this server.
Apache/2.4.38 (Debian) Server at localhost Port 80

Here's the .htaccess from one of the Pico projects.

<IfModule mod_rewrite.c>
    RewriteEngine On
    # May be required to access sub directories
    #RewriteBase /

    # Deny access to internal dirs and files by passing the URL to Pico
    RewriteRule ^(config|content|vendor|CHANGELOG\.md|composer\.(json|lock|phar))(/|$) index.php [L]
    RewriteRule (^\.|/\.)(?!well-known(/|$)) index.php [L]

    # Enable URL rewriting
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]

    <IfModule mod_env.c>
        # Let Pico know about available URL rewriting
        SetEnv PICO_URL_REWRITING 1
    </IfModule>
</IfModule>

# Prevent file browsing
Options -Indexes -MultiViews

Here's the part from apache2.conf

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

#<Directory /srv/>
#   Options Indexes FollowSymLinks
#   AllowOverride None
#   Require all granted
#</Directory>

I have since started a brand new Pico project downloaded from the Pico website that has the default demo page. The sub page in it: /?sub and /?a/very/long/url are show their respective pages. .htaccess in this project and the older projects are the same and have the same permissions.

PhrozenByte commented 3 years ago

Please refer to http://picocms.org/docs/#apache

You must set AllowOverride All in your <Directory /var/www/>…</Directory> section.

notakoder commented 3 years ago

Thank you. That worked. :)