I have this .htaccess file:
Options -Indexes
RewriteEngine on
ErrorDocument 404 /404.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]*)/?(.*)$ ./$1.php
RewriteCond %{THE_REQUEST} \.php
RewriteRule ^(.*)$ - [L,R=404]
However, when I go to localhost/example.php
, it returns a 500 Internal Server Error.
Any help please? Thanks.
EDIT:
The full error message that comes up is:
Not Found
The requested URL /example.php was not found on this server.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
You're most likely getting 500 due to looping error.
Exclude 404.php
from last rule as:
ErrorDocument 404 /404.php
Options -Indexes -MultiViews
RewriteEngine on
RewriteCond %{THE_REQUEST} \.php [NC]
RewriteRule ^(?!404\.php)$ - [L,NC,R=404]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/?(.*)$ ./$1.php [L]
is 404.php actually set in the root of your filesystem?
I'm guessing not.
Try something like ../404.php
BTW: Did you look in your apache log files?
Since you want to hide .php extension in your pages, try to remove that extension from the .htaccess file by doing the following:
Change: ErrorDocument 404 /404.php to ErrorDocument 404 /404
Hope this helps.
JJ
I have gotten this issue. But my error is disk of server is full 100%. You should check your server disk, as a consider solution.
You just Add this code in your .htaccess file
# BEGING WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
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.