.htaccess mod_rewrite > 500 Internal Server Error

别说谁变了你拦得住时间么 提交于 2019-12-17 10:07:02

问题


I am using .htaccess.

My original link is:

http://example.com/CareerDays/index.php?u_type=admin

And I'm trying to make it look like this:

http://example.com/v/admin

The entire code looks like this:

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

And I always get

"500 Internal Server Error"


回答1:


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




回答2:


On my hosting I needed add first line : RewriteBase / until then I get Internal server error too.




回答3:


This RewriteRule would never match...

You have to place the .htaccess in the root directory, with this code:

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



回答4:


Check your ../apache/conf/httpd.conf and look for:

#LoadModule rewrite_module modules/mod_rewrite.so

If the hash sign (#) appears as the first letter, remove it, save it and restart server.




回答5:


That .htaccess doesn't belong in CareerDays. If you write a request to a directory off of the root, the server FIRST checks if the directory exists, if it doesn't it will then give precedence to the ROOT .htaccess. It won't think to check an .htaccess in an unrelated directory.




回答6:


Remove:

Options +FollowSymLinks

Then upload to the root folder in ASCII mode from your FTP client.




回答7:


500 Errors are often the result of file permission errors rather than anything else. Check the permissions on your .htaccess file.

The required permissions vary depending on the environment (I presume this is on Linux - shouldn't be a problem on Widows).



来源:https://stackoverflow.com/questions/5205456/htaccess-mod-rewrite-500-internal-server-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!