简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM