php-apache2-basic-auth-manager icon indicating copy to clipboard operation
php-apache2-basic-auth-manager copied to clipboard

Page Not Found

Open timhtheos opened this issue 9 years ago • 11 comments

When I go to any links, I get:

Not Found

The requested URL /admin/user/add was not found on this server.

I followed the steps as per README, but I can't figure out the cause of the issue.

Thanks. :)

timhtheos avatar Dec 22 '16 13:12 timhtheos

See: http://silex.sensiolabs.org/doc/2.0/web_servers.html

Just add to the .htaccess file in the web folder the following:

<IfModule mod_rewrite.c>
    Options -MultiViews

    RewriteEngine On
    #RewriteBase /path/to/app
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [QSA,L]
</IfModule>

mickare avatar Feb 28 '17 14:02 mickare

Can't figure out how this file would look like if put into the folder under web. I tried to set RewriteBase to /authmanager/web but that didn't work out at all.

rsuarez82 avatar Mar 31 '17 14:03 rsuarez82

I'm having the same problem... adding the snippet of .htaccess above hasn't helped either.

Part of what confuses me is that under the main php-apache2-basic-auth-manager/ directory, there's no index.php or other default file to load ... so how is this supposed to work?

thirstycat avatar Mar 31 '17 19:03 thirstycat

Hey, I think the link describes it all.


Basic

Using the code snippet needs 'mod_rewrite' enabled (see link above).

RewriteBase is the relative path to the root directory of the website. E.g. consider the authmanager application's index.php at the url "http://example.com/admin/users/index.php", then RewriteBase needs to be /admin/users. The .htaccess file should be in the same folder as that index.php file.

If the authmanger's index.php (in folder web is at root level, then you can leave the comment '#' be.

Btw, on a newer apache version you can use FallbackResource index.php in the .htaccess file as alternative (see the link above for more details). I didn't try it yet.


My scenario

So my scenario it looks like this: /var/www/wlan.home/web/ (Website Root defined as VirtualHost in apache config file)

  • index.html (some welcome page - work in progess)

/var/www/wlan.home/web/users/admin (this web folder)

  • index.php
  • .htaccess (new by me added file, with the following content)
AuthName "Admin Area"
AuthType Basic
AuthUserFile /var/www/wlan.home/web/admin/.htpasswd
AuthGroupFile /var/www/wlan.home/web/admin/.htgroups
<Limit GET POST>
  require user admin
  require group groupadmin
</Limit>

<IfModule mod_rewrite.c>
    Options -MultiViews

    RewriteEngine On
    RewriteBase /admin/users
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [QSA,L]
</IfModule>

/var/www/wlan.home/css

  • bootstrap and font

/var/www/wlan.home/fonts

  • font stuff

/var/www/wlan.home/private/php-auth-manager

  • all other authmanager dependencies (yes, i moved it all outside of the website root directory).

Greetings, mike

mickare avatar Mar 31 '17 20:03 mickare

We should add this to the readme.

DanielRuf avatar May 08 '17 15:05 DanielRuf

I've spend hours try to get this work on an Ubuntu 16.04. Also with the explanation from @mickare it doesn't work! I've also renamed all folders to make them equal to the scenario above. Additionally I followed those hints on https://stackoverflow.com/questions/7816429/apache-mod-rewrite-is-not-working-or-not-enabled. This tool like looks really nice and handy but now I'm really frustrated and giving up. :-(

patschwork avatar Jul 07 '17 09:07 patschwork

@patschwork, hey!

First, let's be sure you have mod_rewrite running on your machine. On Ubuntu/Debian you have a handy way to do this:

sudo a2enmod rewrite
=> Module rewrite already enabled

If not enable, will be after you restart Apache:

sudo service apache2 restart

About the Stackoverflow link you sent, AllowOverride None seems a bad option (will not allow .htaccess to work fine). AllowOverride All seems correct. On the same linkthere's a comment from Jarrod pointing to good article about enabling mod_rewrite on Apache2 - http://www.jarrodoberto.com/articles/2011/11/enabling-mod-rewrite-on-ubuntu.

By the way: this is not mandatory to this project to work, but VERY important for security reasons.

rafaelgou avatar Jul 07 '17 10:07 rafaelgou

Hi @rafaelgou, thank you for the reply. Your described steps were the first things I made ;-)

patschwork avatar Jul 12 '17 13:07 patschwork

Hi @patschwork sad to hear that it does not work. But what exactly does not work? Is the main page visible?

Greetings, mike

mickare avatar Jul 12 '17 13:07 mickare

Hi @mickare, I experimented with the .htaccess file as you mentioned above and researched on the web (with restarting the browser after each change to get a clean load). Depending on the .htaccess config I had two erronous scenario: HTTP 500 and a blank page when I opened the main page (private tab to get clean cookies, assets etc.).

(I want to you use php-apache2-basic-auth-manager in besides the yii2-framework)

Bye, Patrick

virtualHost file:

<VirtualHost *:80>
    Alias /meta_grid_dev "/var/www/meta_grid_dev/"

    <Directory "/var/www/meta_grid_dev">
    Options +FollowSymLinks
    AllowOverride All
    SetEnv HOME /var/www/meta_grid_dev
    SetEnv HTTP_HOME /var/www/meta_grid_dev
    </Directory>

    #<Directory "/var/www/meta_grid_dev/">
    #  # just in case if .htaccess gets disabled
    #  Require all denied
    #</Directory>

    #SSLEngine on
    #SSLCertificateFile /etc/ssl/certs/apache.crt
    #SSLCertificateKeyFile /etc/ssl/private/apache.key
</VirtualHost>

.htaccess:

AuthName "Members Area"
AuthType Basic
AuthUserFile /var/www/meta_grid_dev/.htpasswd
AuthGroupFile /var/www/meta_grid_dev/.htgroups
<Limit GET POST>
  require user superuser
  #require group admin
</Limit>

<IfModule mod_rewrite.c>
    Options -MultiViews

    RewriteEngine On
    RewriteBase /php-apache2-basic-auth-manager
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [QSA,L]
</IfModule>

config.yml:

# Base URL
baseUrl: http://localhost/meta_grid_dev/php-apache2-basic-auth-manager

# Path to Apache2 files
htpasswd: '/var/www/meta_grid_dev/.htpasswd'
htgroups: '/var/www/meta_grid_dev/.htgroups'

# Debug
debug: false

patschwork avatar Jul 15 '17 15:07 patschwork

<IfModule mod_rewrite.c>

If you depend on that module for you application, do not conditionally load it when available. Instead remove, the IfModule so you get hard errors if Apache can't parse the Rewrite directives. If you rely on something don't silently ignore errors ;-)

Rillke avatar Dec 09 '19 01:12 Rillke