Mod rewrite ошибка 500

When you put configuration directives in a .htaccess file, and you don’t get the desired effect, there are a number of things that may be going wrong.

Most commonly, the problem is that AllowOverride directive in httpd.conf file is not set such that your configuration directives are being honored. Make sure that you don’t have a AllowOverride None in effect for the file scope in question. A good test for this is to put garbage in your .htaccess file and reload the page. If a server error is not generated, then you almost certainly have AllowOverride None in effect.

If, on the other hand, you are getting server errors when trying to access documents, check your httpd error log. It will likely tell you that the directive used in your .htaccess file is not permitted.

[Fri Sep 17 18:43:16 2010] [alert] [client 192.168.200.51]
/var/www/html/.htaccess: DirectoryIndex not allowed here

This will indicate either that you’ve used a directive that is never permitted in .htaccess files, or that you simply don’t have AllowOverride set to a level sufficient for the directive you’ve used. Consult the documentation for that particular directive to determine which is the case.

Alternately, it may tell you that you had a syntax error in your usage of the directive itself.

[Sat Aug 09 16:22:34 2008] [alert] [client 192.168.200.51]
/var/www/html/.htaccess: RewriteCond: bad flag delimiters

In this case, the error message should be specific to the particular syntax error that you have committed.

You must have AllowOverride set to ‘All’ or ‘FileInfo’ in httpd.conf file for having permissions of mod_rewrite directives in .htaccess file.

http://httpd.apache.org/docs/2.2/howto/htaccess.html

i made a simple .htaccess file to expose the problem.

I want that all request made to the folder redirect to a subfolder file «app/index.php»

RewriteEngine On

RewriteRule (.*) app/index.php [QSA]

And this works fine on with the basic url of my hoster (like http//myname.hosting.com/htaccessFolder

The problem is that i have a domain pointing on this folder, and when accessed to it, server return Internal Server Error 500.

If i do this :

RewriteEngine On

RewriteRule (.*) somefile.php [QSA]

Redirection works only when file does not exists (404 not found error occured). when the file exists i get a 500 error too.

I’ve asked the hosting support without success for the moment..

EDIT :

Strangely, when i write :

RewriteEngine On

RewriteRule (.*) somefile.txt [QSA]

it works on bot, so it seems that the problem comes from executing php files..

EDIT2 :

Here is the real .htaccess file i try to use :

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #RewriteCond %{REQUEST_FILENAME} -f 
    #RewriteRule .? - [L]

    #####################

    RewriteRule (.*) app/public/$1

    RewriteCond %{REQUEST_FILENAME} -f 
    RewriteRule .? - [L]

    RewriteRule app/public/(.*) $1



    #####################

    #RewriteCond %{REQUEST_FILENAME} question2answers/(.+)
    #RewriteRule .? - [L]

    #####################

    #RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteRule (.*) index.php [L,QSA]

</IfModule>

You can see that only the public block is not commented but when i go to the website i get this :
The requested URL /cgi-bin/php5.fcgi/index.php/index.php/index.php/index.php/index.php/index.php/index.php/in…..

but i request a file in the public folder (like http://website.com/css/style.css (which is in public/css) it works as expected.
When i’m not commenting the last block, i get a 500 error.

(I have answered a post like that not so long ago, although here the situation differs a little)

Say someone goes to a.domain.com. This matches both conditions.

The main problem: your rewrite rule matches an empty input…

So, a.domain.com goes through the rule and becomes a.domain.com/shopping/gatename/.

And then it goes back to the server again, and matches again both conditions. The URL becomes a.domain.com/shopping/gatename/shoppin/gatename/.

Have you noticed? It substitute with the value of the request, not what you captured in your second RewriteCond, and there lies your other problem.

You can reuse groups captured by RewriteCond but they are preceded with %, not $. Hence, what you want really is this (with full regex metacharacters etc plus anchors):

RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
# Non capturing group for "www." if present: it is of no interest
RewriteCond %{HTTP_HOST} ^(?:www\.)([a-z0-9-]+)\.domain\.com$ [NC]
RewriteRule (.*) http://www.domain.com/shopping/gatename/%1/$1 [L] # Note the %!

Когда вы вставляете директивы конфигурации в файл .htaccess и не получаете желаемого эффекта, есть ряд вещей, которые могут пойти не так.

Чаще всего проблема заключается в том, что директива AllowOverride в файле httpd.conf не установлена ​​таким образом, что ваши директивы конфигурации соблюдаются. Убедитесь, что у вас нет разрешения AllowOverride None для рассматриваемой области файла. Хорошим испытанием для этого является поместить мусор в ваш файл .htaccess и перезагрузить страницу. Если ошибка сервера не сгенерирована, вы почти наверняка имеете AllowOverride None.

Если, с другой стороны, вы получаете ошибки сервера при попытке доступа к документам, проверьте свой журнал ошибок httpd. Вероятно, вам скажут, что директива, используемая в вашем файле .htaccess, не разрешена.

[Пт сен 17 18:43:16 2010] [alert] [клиент 192.168.200.51] /var/www/html/.htaccess: DirectoryIndex не разрешен здесь

Это укажет либо на то, что вы использовали директиву, которая никогда не разрешена в файлах .htaccess, или что у вас просто нет AllowOverride, установленного на уровень, достаточный для используемой вами директивы. Обратитесь к документации по этой конкретной директиве, чтобы определить, в чем дело.

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

[Sat Aug 09 16:22:34 2008] [alert] [клиент 192.168.200.51] /var/www/html/.htaccess: RewriteCond: неверные разделители флагов

В этом случае сообщение об ошибке должно быть специфичным для конкретной ошибки синтаксиса, которую вы совершили.

У вас должен быть установлен параметр AllowOverride ‘All’ или ‘FileInfo’ в файле httpd.conf для получения разрешений директив mod_rewrite в файле .htaccess.

http://httpd.apache.org/docs/2.2/howto/htaccess.html

На моем хостинге мне нужно добавить первую строку: RewriteBase / до тех пор, пока я не получу внутреннюю ошибку сервера.

Этот RewriteRule никогда не будет соответствовать …

Вы должны поместить .htaccess в корневой каталог с этим кодом:

 RewriteEngine On RewriteRule ^v/([^/]*)$ CareerDays/index.php?u_type=$1 [L] 

Этот .htaccess не принадлежит CareerDays. Если вы пишете запрос в директорию с корня, сервер FIRST проверяет, существует ли каталог, если он этого не сделает, тогда будет приоритет ROOT .htaccess. Он не think проверить .htaccess в несвязанной директории.

Удалить:

 Options +FollowSymLinks 

Затем загрузите в корневую папку в режиме ASCII с вашего FTP-клиента.

500 Ошибки часто являются результатом ошибок разрешения файлов, а не всего остального. Проверьте разрешения на файл .htaccess.

Необходимые разрешения зависят от среды (я полагаю, это на Linux – не должно быть проблемой для Вдовов).

Проверьте свой ../apache/conf/httpd.conf и найдите:

 #LoadModule rewrite_module modules/mod_rewrite.so 

Если знак хеша (#) появляется как первая буква, удалите его, сохраните и перезапустите сервер.

I wanted to replace the .html extensions with just nothing in apache.

Eg. DNS/coffee.html to be DNS/coffee. I found myself this code.

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/?$ $1.html [L]
</IfModule>

It does the job I wanted, but it doesn’t.

It seems to not like 404.html for errors. Everytime I open a page that doesn’t exist, it doesn’t give me the 404 page anymore, but a 500 internal server error message:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at EMAIL to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.4.41 (Ubuntu) Server at URL Port 443

I don’t know what I am suposed to do, google doesn’t give me wise answers, only things like “how to redirect a page to 404.html” or “how to make every link that doesn’t go to this DNS reditect to 404 page.”

Here is the code for .htaccess.

# ------------------Error Pages--------------------
# 404 NOT FOUND
ErrorDocument 404 /errors/404.html
# -----------------Rem .html and .htm extensions---
 
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/?$ $1.html [L]
</IfModule>

Понравилась статья? Поделить с друзьями:
  • Mitsubishi f700 ошибка p5
  • Mod organizer ошибка приложения 0xc000007b
  • Mitsubishi electric ошибки на пульте
  • Mod organizer ошибка при запуске
  • Mitsubishi electric ошибки индикация led