1

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.

0

2 Answers 2

2

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]
Sign up to request clarification or add additional context in comments.

6 Comments

It does work allmost, except that it cannot load .css files or images.
Is it possible to send all to index.php except preconfigured files as .css, .png, jpg etc
For that you can add this in the <head> section of your page's HTML: <base href="/" /> so that every relative URL is resolved from that base URL and not from the current page's URL.
I just made af google search and found this: RewriteRule !\.(js|ico|gif|jpg|png|css|html|swf|flv|xml)$ index.php [QSA,L] - How can I implement that?
That's not needed actually since I already have RewriteCond %{REQUEST_FILENAME} !-f. You have use <base...> tag as I wrote above.
|
0

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

1 Comment

is it possible to send all to index.php except .css, .png, jpg etc.

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.