Я пытаюсь настроить проект в своей локальной среде, поэтому я могу поработайте над этим. Используется PHP 5.3.3 и Apache 2.2.15 с CodeIgniter 2.3.1 (версии PHP и CI здесь не актуальны, а просто к сведению в случае необходимости).
Я установил VH следующим образом :
<VirtualHost *:80>
DocumentRoot "/var/www/html/document_api/public"
ServerName document.api.localhost
<Directory "/var/www/html/document_api/public">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
LogLevel debug
</VirtualHost>
И файл проекта /var/www/html/document_api/public/.htaccess
выглядит следующим образом:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
#Rule 2: IF a file exists when .php is added, then rewrite URL by adding .php
RewriteRule ^([0-9A-_Za-z]+)$ $1.php [L]
RewriteCond %{REQUEST_FILENAME}.php !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Как только я пытаюсь нажать URL-адрес для document.api .localhost: 8080
У меня следующие ошибки:
[Mon Jan 22 17:25:50 2018] [error] [client 10.0.2.2] Directory index forbidden by Options directive: /var/www/html/document_api/public/
[Mon Jan 22 17:25:50 2018] [error] [client 10.0.2.2] File does not exist: /var/www/error
[Mon Jan 22 17:25:51 2018] [error] [client 10.0.2.2] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://document.api.localhost:8080/
[Mon Jan 22 17:25:51 2018] [debug] core.c(3112): [client 10.0.2.2] r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/favicon.ico, referer: http://document.api.localhost:8080/
[Mon Jan 22 17:25:51 2018] [debug] core.c(3118): [client 10.0.2.2] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/favicon.ico, referer: http://document.api.localhost:8080/
[Mon Jan 22 17:25:51 2018] [debug] core.c(3118): [client 10.0.2.2] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/favicon.ico, referer: http://document.api.localhost:8080/
[Mon Jan 22 17:25:51 2018] [debug] core.c(3118): [client 10.0.2.2] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/index.php/favicon.ico, referer: http://document.api.localhost:8080/
[Mon Jan 22 17:25:51 2018] [debug] core.c(3118): [client 10.0.2.2] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/index.php/favicon.ico, referer: http://document.api.localhost:8080/ [Mon Jan 22 17:25:51 2018] [debug] core.c(3118): [client 10.0.2.2] redirected from r->uri = /index.php/index.php/index.php/index.php/index.php/favicon.ico, referer: http://document.api.localhost:8080/
[Mon Jan 22 17:25:51 2018] [debug] core.c(3118): [client 10.0.2.2] redirected from r->uri = /index.php/index.php/index.php/index.php/favicon.ico, referer: http://document.api.localhost:8080/
[Mon Jan 22 17:25:51 2018] [debug] core.c(3118): [client 10.0.2.2] redirected from r->uri = /index.php/index.php/index.php/favicon.ico, referer: http://document.api.localhost:8080/
[Mon Jan 22 17:25:51 2018] [debug] core.c(3118): [client 10.0.2.2] redirected from r->uri = /index.php/index.php/favicon.ico, referer: http://document.api.localhost:8080/
[Mon Jan 22 17:25:51 2018] [debug] core.c(3118): [client 10.0.2.2] redirected from r->uri = /index.php/favicon.ico, referer: http://document.api.localhost:8080/
[Mon Jan 22 17:25:51 2018] [debug] core.c(3118): [client 10.0.2.2] redirected from r->uri = /favicon.ico, referer: http://document.api.localhost:8080/
Я что-то здесь упускаю? Что не так в этой настройке?
В вашем лог-файле есть две проблемы. Первая - индекс каталога запрещен, что вызвано работой
RewriteCond %{REQUEST_FILENAME} !-d
Запрошенный путь - это явно каталог, это каталог DocumentRoot
. Таким образом, перенаправление правила на PHP пропускается. И вы, вероятно, не имеете index.php
в качестве вашего DirectoryIndex
и список каталогов запрещен (documentation).
Вторая проблема, бесконечный редирект, вызван другим запросом, на этот раз браузером, запрашивающим favicon.ico
. Файл не существует и переписан на index.php/favicon.ico
, но такого файла или папки нет, он переписан на index.php/index.php/favicon.ico
и так далее.
Вам, вероятно, следует пропустить перенаправление на index.php/something
и изменить его на GET-параметры, я не вижу причин, по которым вы пытаетесь перенаправить его таким образом. /index.php?path=something
имело бы больше смысла.