0

the following htaccess rule will redirect files without extension (contact) to (contact.php) but it also run on folders

I want it to run only on files only and skip running on folders

RewriteEngine on
RewriteBase /
Options +MultiViews
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>

7
  • RewriteCond %{REQUEST_FILENAME} !-f !-d Commented Sep 1 at 14:49
  • Iłya Bursov , error 500 Internal Server Error ,RewriteCond: bad flag delimiters, Commented Sep 1 at 14:53
  • ah, yes, they should be separate lines RewriteCond %{REQUEST_FILENAME} !-f and next RewriteCond %{REQUEST_FILENAME} !-d Commented Sep 1 at 15:03
  • @IłyaBursov Please post answers in the answer box below. Comments are for clarification only. Commented Sep 1 at 15:06
  • "following htaccess rule will redirect files without extension" - it doesn't redirect "files" at all. It rewrites URLs which do not map to files. Commented Sep 1 at 15:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.