Chak
Chak

Reputation: 71

URL rewrite all php files in subfolder to index.php

I am trying to setup a way to rewrite all php files in a subfolder to index.php

What I have been trying until now:

RewriteEngine on

RewriteBase /simple

RewriteRule ^(.+)/$ index.php

It does not work 100%, now it takes the CSS, IMG and all other files too, which it should not, only the PHP files.

Hope some can help. Thank you.

Upvotes: 1

Views: 543

Answers (2)

anubhava
anubhava

Reputation: 785286

You can use:

DirectoryIndex index.php
RewriteEngine on
RewriteBase /simple/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

Or this rule:

RewriteRule !\.(js|ico|gif|jpe?g|png|css|html|swf|flv|xml)$ index.php [L,NC]

Upvotes: 2

David Kmenta
David Kmenta

Reputation: 850

RewriteRule ^(.+)\.php$ index.php is the way

Upvotes: 0

Related Questions