M
M
ms23452015-09-27 16:10:17
htaccess
ms2345, 2015-09-27 16:10:17

How to direct all requests to one file?

Good afternoon. There is a certain file: index.php
And it is necessary that all requests, regardless of the url, be sent to it, except for those requests where file permissions are specified, for example:
mydomian.com/users/ - redirects to index.php
mydomian.com/users.html - redirects to users.html
mydomian.com/images/contacts.png - redirects to contacts.png
mydomian.com/images/awdawd?value=adawd&value_2=adawd - redirects to index.php
Please help me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Sidorenko, 2015-09-30
@sidorenkoda

If there is no such file or directory on the server, then everything will go to index.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

And it's possible like this:
RewriteEngine on
RewriteRule [%,a-zA-Z0-9/-/+/()] index.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question