Forum Moderators: phranque
My server is hostpc which supports mod_rewrite
I am attempting to hide the .php extension i.e. www.example.com/home.php into www.example.com/home for SEO purposes
However, when I go to www.example.com/home, there is a 404 error that says:
The requested URL /home was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
My .htaccess is as follows:
#<Limit GET POST>
#order deny,allow
#deny from all
#allow from all
#</Limit>
#<Limit PUT DELETE>
#order deny,allow
#deny from all
#</Limit>
php_value register_globals 0
RewriteEngine On
RewriteBase /
#RewriteCond %{REQUEST_FILENAME}\.php!-f
#RewriteRule . /%{REQUEST_FILENAME}\.php
#RewriteCond %{REQUEST_FILENAME}!-d
#RewriteRule (.*) /$1\.php [L]
#RewriteCond %{REQUEST_FILENAME}!-d [AND]
RewriteCond ^%{REQUEST_FILENAME}[\.php]$ -f
RewriteRule (.*) /$1.php [L]
#DefaultType application/x-httpd-php
#ForceType application/x-httpd-php
I have NO idea what is wrong for it works on my other server but not hostpc's
Thanks alot
Removing the commented-out lines and fixing what's left, we get:
php_value register_globals 0
#
RewriteEngine on
RewriteBase /
#
# Check whether requested URL-path exists as a file when ".php" is appended to it
RewriteCond %{REQUEST_FILENAME}\.php -f
# Rewrite URL-paths which do not contain a period by appending ".php" (if the file exists)
RewriteRule ^([^.]+)$ /$1.php [L]
Jim