Henson
Henson

Reputation: 5913

htaccess in localhost help

My url is something like this

localhost/luz/home -> read home.php file
localhost/luz/content/about -> read content.php?page=about

But somehow it doesn't work completely.

localhost/luz/home -> SUCCESS
localhost/contenttt -> internal server error (contenttt.php doesn't exist and the 404 doesn't work)
localhost/content/about -> somehow it loads content.php?page=about.php/about

My htaccess is simple

RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
RewriteRule ^(.*)$ $1.php
RewriteRule ^content/(.*)$  content.php?page=$1
ErrorDocument 404 /404.php

Upvotes: 0

Views: 213

Answers (1)

Gumbo
Gumbo

Reputation: 655129

You should check if the substitution actually references an existing file:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

Otherwise you will get an infinite recursion that adds .php at the end every time.

Upvotes: 1

Related Questions