2014-10-21 4 views
0

Я установил http-аутентификацию для одного из моих сайтов. Веб-приложение построено с использованием воспламенителя кода и настраиваемой маршрутизации URI. После изменения файла .conf для сайта у меня возникли ошибки 404 Not Found при попытке доступа к любой из страниц, кроме главной страницы. Например, перейдя в /about, которая работала до аутентификации HTTP, не дает 404 с сообщением:Почему моя HTTP-аутентификация не работает?

The requested URL /about was not found on this server. 

Apache/2.4.7 (Ubuntu) Server at example.com Port 80 

Почему апач посылает запрос на «/` директории? Файл .conf (слегка адаптированный для безопасности) в местах с поддержкой является следующее:

<VirtualHost *:80> 
# The ServerName directive sets the request scheme, hostname and port that 
# the server uses to identify itself. This is used when creating 
# redirection URLs. In the context of virtual hosts, the ServerName 
# specifies what hostname must appear in the request's Host: header to 
# match this virtual host. For the default virtual host (this file) this 
# value is not decisive as it is used as a last resort host regardless. 
# However, you must set it for any further virtual host explicitly. 

ServerName example.com 

DirectoryIndex index.php 
ServerAdmin [email protected] 
DocumentRoot /home/user/codeigniter 

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 
# error, crit, alert, emerg. 
# It is also possible to configure the loglevel for particular 
# modules, e.g. 
#LogLevel info ssl:warn 

ErrorLog /home/user/logs/codeigniter/error.log 
CustomLog /home/user/logs/codeigniter/access.log combined 

# For most configuration files from conf-available/, which are 
# enabled or disabled at a global level, it is possible to 
# include a line for only one particular virtual host. For example the 
# following line enables the CGI configuration for this host only 
# after it has been globally disabled with "a2disconf". 
#Include conf-available/serve-cgi-bin.conf 

<Directory /home/user/codeigniter/> 
    # Options Indexes FollowSymLinks Includes ExecCGI 
    # AllowOverride All 
    # Require all granted 
    AuthType Basic 
    AuthName "Beta Site" 
    # (Following line optional) 
    AuthBasicProvider file 
    AuthUserFile /var/www/passwd/passwords 
    Require user user 
</Directory> 

ответ

1

В определении Справочник < Каталог/главная/пользователя/CodeIgniter >, вам нужно изменить:

# AllowOverride All 

в

AllowOverride All 

и Restar t apache.

Без этого файл .htaccess в корне вашего документа не будет работать, и вы сможете получить доступ к нему через uri /index.php/about.

+0

Ах спасибо, глупая ошибка. – Wold