500 internal server error with RewriteRule php
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-\s]+)/([a-zA-Z0开发者_如何转开发-9_-\s]+)/([a-zA-Z0-9_-\s()]+)/?$ product.php?group=$1&salt=$2&name=$3 [L]
It was working fine with my previous hosting but when i change my hosting to 1and1 (Linux) its gives me 500 internal server error. Please help me whats going on? Thanks
Are you absolutely sure that your new provider has mod_rewrite
enabled? Its the most common reason for seeing 500 errors with mod_rewrite
.
To make a quick test just replace your complete .htaccess
with the following lines (make a backup of your original .htaccess
first)
RewriteEngine on
RewriteRule ^(.*)$ http://www.google.com [R]
If mod_rewrite
is enabled it will redirect all your requests to Google.
The correct way to install mod rewrite would be to use <IfModule mod_rewrite.c>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-\s]+)/([a-zA-Z0-9_-\s]+)/([a-zA-Z0-9_-\s()]+)/?$ product.php?group=$1&salt=$2&name=$3 [L]
</IfModule>
This will ensure the mod rewrite is only run if mod_rewrite is installed. This should at least stop the server error. If it doesn't this means you've got a syntax error with your rewrite rule.
精彩评论