U
U
utyfua2016-09-11 17:33:10
htaccess
utyfua, 2016-09-11 17:33:10

Redirect with htaccess if required file exists?

Good afternoon
I now have such an interesting line: RewriteRule ^(.*)$ index.php?htaccess&l=$1 [L,QSA]But you can immediately see that everything is through one file and this is a bad habit ..
I would like to start breaking everything down, but I'm not ready to change everything right away.
Is it possible to somehow "combine" that line with RewriteRule ^(([^/]+/)*[^.]+)$ $1.php [L,QSA]if the desired file really exists and is located in this folder or in the folder, say, code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2016-09-11
@utyfua

RewriteEngine on

RewriteCond %{REQUEST_URI} ^.*([^/.]+)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/.]+)$ sys/$1.php [QSA,L]

RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question