0

The code is mixed to I have .html and .php in the same folder. There is never a time there there is the same name but different extensions. I have some code that should work but doesn't. The html part works but when I try to request a PHP page without an extension the URL it gives a 404

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -F RewriteRule ^(.*)$ $1.html RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -F RewriteRule ^(.*)$ $1.php 
4
  • You are likely never getting past the first set of conditions in your .htaccess file. There is no way for Apache to know whether it should be looking for a html file or a php file given the conditions you have stated. Commented Apr 30, 2018 at 19:38
  • Yeah, that's the problem. I don't know how to skip the first rule if the cond is false. Commented Apr 30, 2018 at 19:44
  • Try changing the upper case -F's to lower case -f instead. Also check out this question Commented Apr 30, 2018 at 19:49
  • @Dave i've tried with lowercase -f and it still didn't work and i do have multiviews off Commented Apr 30, 2018 at 19:52

1 Answer 1

2

You can try this on the .htaccess file:

RewriteEngine On RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule (.*) $1.php [L] RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule (.*) $1.html [L] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.