简体   繁体   中英

.htaccess (500 Internal Server Error) - removing file extension in url

Here is my source code.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC]

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at admin@example.com 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.

First of all make sure your apache has mod_rewrite on. I could explain how to do it on Linux, but since you have WAMP on Windows, it is different there, but sure you can google for it to find out.

Second, your RewriteRule is missing [L] flag which would tell to Apache that this is a last rule to be applied for this request. But this missing flag would not cause error you give in comments. So first option to look for is to whether mod_rewrite is enabled or not.

As someone suggested in comments: please take a look at this answer, it gives whole walkthrough on how to enable mod_rewrite: https://stackoverflow.com/a/13633635/1297136

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