Suneth Kalhara
Suneth Kalhara

Reputation: 1221

htaccess rewrite rule preventing access newly added php files

I have a website with htaccess file. the htaccess has lot of codes. when I create a new php file it redirects to another page. so I checked my htaccess file and remove a one line of code

RewriteRule ^.*\.{1}(htm|html|php)\/?   index.php [L,QSA,NC]

after that the file can can able to access diretly. can anyone know the meaning of above htacess and how can it effect for newly added php files.

Upvotes: 1

Views: 56

Answers (1)

anubhava
anubhava

Reputation: 785481

This rule:

 RewriteRule ^.*\.{1}(htm|html|php)\/?   index.php [L,QSA,NC]

is silently forwarding every request URI with extension .php OR .htm OR .html to index.php

So even if you add a new .php above regex ^.*\.{1}(htm|html|php)\/? will match and request for the newly created file will still be forwarded to index.php

PS: This rule doesn't make lot sense though a similar looking rule is used in many front controllers like Wordpress, CodeIgnitor, Cake etc frameworks.

Reference: Apache mod_rewrite Introduction

Upvotes: 1

Related Questions