0

When i am using rewrite rule in .htaccess it seems an internal server error occurs

My .htaccess code is as follows:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.$ $1.php [nc]
RewriteRule  ^([a-z][a-zA-Z0-9_-]+)\.htm$ inner.php?url=$1

But I get an server error. The error message is as follows:

Internal Server Error

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

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

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

1
  • Like the page says, check your server error log for details. My first guess would be that Options +FollowSymlinks has been disabled by your server administrator.
    – user149341
    May 25, 2012 at 16:55

1 Answer 1

0
RewriteRule ^(.*).$ $1.php [nc]
RewriteRule ^([a-z][a-zA-Z0-9_-]+).htm$ inner.php?url=$1

Can you please explain, what you aim to achieve with the first rule?

Right now it would rewrite any file to one that is named the same (except last char) and extended with ".php":

abcdefg becomes abcdef.php < is that what you want?

The real problem is that this happens over and over again: After the first rewrite htaccess is called a second time and the rules apply again since there is no condition limiting the rewrites.

Try this:

RewriteCond %{REQUEST_URI} !\.php$    # if the uri does not end with ".php"
RewriteRule ^(.*).$ $1.php [nc,L]     # do not apply another rule after this

RewriteRule ^([a-z][a-zA-Z0-9_-]+).htm$ inner.php?url=$1

Regards, STEFAN

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.