ErrorDocument удаляет файл .htaccess

Если я добавлю директиву ErrorDocument в файл .htaccess, все перестанет работать. Теперь знаю, где моя ошибка. Затем я удаляю директиву ErrorDocument, все снова работает.

Я пытался использовать путь относительно корня документа или полный URL-адрес. Пробовал также сделать в корне документа отдельную папку /err/errMsg.php и ссылаться на нее ErrorDocument 100 http://localhost/domainname.biz/err/errMsg.php , все же лучше было бы перенаправить на public/index.php/err/err action.

Мой корень документа:

DOCUMENT_ROOT   /home/name/public_html/domainname.biz  on server 
DOCUMENT_ROOT   ...../apache2/htdocs    on localhost

.htaccess файл для localhost :

ErrorDocument 100  /domainname.biz/public/index.php/err/err
#i also used ErrorDocument 100 http://localhost/domainname.biz/public/index.php/err/err
ErrorDocument 101  /domainname.biz/public/index.php/err/err
ErrorDocument 102  /domainname.biz/public/index.php/err/err
ErrorDocument 200  /domainname.biz/public/index.php/err/err
ErrorDocument 201  /domainname.biz/public/index.php/err/err
ErrorDocument 202  /domainname.biz/public/index.php/err/err
ErrorDocument 203  /domainname.biz/public/index.php/err/err
ErrorDocument 204  /domainname.biz/public/index.php/err/err
ErrorDocument 205  /domainname.biz/public/index.php/err/err
ErrorDocument 206  /domainname.biz/public/index.php/err/err
ErrorDocument 207  /domainname.biz/public/index.php/err/err
ErrorDocument 226  /domainname.biz/public/index.php/err/err
ErrorDocument 300  /domainname.biz/public/index.php/err/err
ErrorDocument 301  /domainname.biz/public/index.php/err/err
ErrorDocument 302  /domainname.biz/public/index.php/err/err
ErrorDocument 303  /domainname.biz/public/index.php/err/err
ErrorDocument 304  /domainname.biz/public/index.php/err/err
ErrorDocument 305  /domainname.biz/public/index.php/err/err
ErrorDocument 306  /domainname.biz/public/index.php/err/err
ErrorDocument 307  /domainname.biz/public/index.php/err/err
ErrorDocument 400  /domainname.biz/public/index.php/err/err
ErrorDocument 401  /domainname.biz/public/index.php/err/err
ErrorDocument 402  /domainname.biz/public/index.php/err/err
ErrorDocument 403  /domainname.biz/public/index.php/err/err
ErrorDocument 404  /domainname.biz/public/index.php/err/err
ErrorDocument 405  /domainname.biz/public/index.php/err/err
ErrorDocument 406  /domainname.biz/public/index.php/err/err
ErrorDocument 407  /domainname.biz/public/index.php/err/err
ErrorDocument 408  /domainname.biz/public/index.php/err/err
ErrorDocument 409  /domainname.biz/public/index.php/err/err
ErrorDocument 410  /domainname.biz/public/index.php/err/err
ErrorDocument 411  /domainname.biz/public/index.php/err/err
ErrorDocument 412  /domainname.biz/public/index.php/err/err
ErrorDocument 413  /domainname.biz/public/index.php/err/err
ErrorDocument 414  /domainname.biz/public/index.php/err/err
ErrorDocument 415  /domainname.biz/public/index.php/err/err
ErrorDocument 416  /domainname.biz/public/index.php/err/err
ErrorDocument 417  /domainname.biz/public/index.php/err/err
ErrorDocument 422  /domainname.biz/public/index.php/err/err
ErrorDocument 423  /domainname.biz/public/index.php/err/err
ErrorDocument 424  /domainname.biz/public/index.php/err/err
ErrorDocument 426  /domainname.biz/public/index.php/err/err
ErrorDocument 500  /domainname.biz/public/index.php/err/err
ErrorDocument 501  /domainname.biz/public/index.php/err/err
ErrorDocument 502  /domainname.biz/public/index.php/err/err
ErrorDocument 503  /domainname.biz/public/index.php/err/err
ErrorDocument 504  /domainname.biz/public/index.php/err/err
ErrorDocument 505  /domainname.biz/public/index.php/err/err
ErrorDocument 506  /domainname.biz/public/index.php/err/err
ErrorDocument 507  /domainname.biz/public/index.php/err/err
ErrorDocument 510  /domainname.biz/public/index.php/err/err

Options -MultiViews
Options -Indexes

Options +FollowSymlinks
# +FollowSymLinks must be enabled for any rules to work, this is a security requirement of the rewrite engine. 
# Normally it's enabled in the root and you shouldn't have to add it, but it doesn't hurt to do so, 
# Although highly unlikely, your host may have +FollowSymLinks enabled at the root level, 
# yet disallow its addition in .htaccess; in which case, adding +FollowSymLinks will break your setup
#  (probably a 500 error), so just remove it, and your rules should work fine.

RewriteEngine on
RewriteBase /
IndexIgnore *  


RewriteCond %{HTTP_HOST} ^domainname\.biz [NC]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI}


RewriteCond %{HTTP_HOST} ^www.domainname\.biz [NC]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}



RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{ENV:REQUEST_FILENAME} !-d
RewriteCond %{ENV:REQUEST_FILENAME} !-f
RewriteCond %{ENV:REQUEST_FILENAME} !-l

RewriteRule ^index.php?(.+)$ index.php?url=$1 [QSA,L] 

.htaccess файл на сервере такой же, но я начинаю с другого корня документа

ErrorDocument 100  /public/index.php/err/err
#or https://www.domainname.biz/public/index.php/err/err

person olga    schedule 05.04.2017    source источник


Ответы (1)


Не уверен, почему у вас так много строк ErrorDocument в вашем .htaccess:

Как минимум удалите строку для неподдерживаемого кода ответа 306, чтобы избежать внутренней ошибки 500 на вашем сайте.

Вы также должны удалить обработанный код ответа 200, так как это хороший статус.

person anubhava    schedule 05.04.2017
comment
Спасибо. Кажется, 306 было причиной. Я взял эти коды с сайта askapache.com/htaccess/apache-status- code-headers-errordocument и askapache.com/php/php-errordocument Я оставил 200, потому что хотел проверить, работает ли. - person olga; 05.04.2017
comment
Извините, это работает только на локальном хосте, а не на удаленном сервере. - person olga; 05.04.2017
comment
я получаю страницу: 500 Произошла внутренняя ошибка. Сервер обнаружил внутреннюю ошибку или неправильную конфигурацию и не смог выполнить ваш запрос. Кроме того, при попытке использовать ErrorDocument для обработки запроса возникла ошибка 404 Not Found. - person olga; 05.04.2017
comment
На моем Apache только 306 выдавал 500 внутренних ошибок сервера. Вам нужно будет проверить error.log на удаленном сервере, чтобы узнать причину этой ошибки. - person anubhava; 05.04.2017
comment
- [05/Apr/2017:00:08:41 -0700] GET /public/index.php/security/login HTTP/1.1 200 6349 - Mozilla/5.0 (совместимо; Baiduspider/2.0; +baidu.com/search/spider.html) - person olga; 05.04.2017
comment
Я вижу только ошибку 200. Vierd. дайте мне больше времени, чтобы понять, ПОЧЕМУ. Если удалить директивы ErrorDocument, ошибок не возникает - все работает. Сейчас поменял, оставил только коды 400 и 500. - person olga; 05.04.2017
comment
Журнал ошибок не имеет смысла, потому что он показывает URL-адрес, который я вообще не посещал: я разместил его в вопросе - person olga; 06.04.2017
comment
Вам не нужно указывать полный путь к файловой системе. Просто попробуйте DrrorXocument 404 /index.php/err - person anubhava; 06.04.2017