A
A
Arris2015-09-06 13:31:45
Apache HTTP Server
Arris, 2015-09-06 13:31:45

Mod_rewrite, unusual routing, how to make a proper redirect?

There is such a non-standard routing:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

#project settings (1)
RewriteRule ^([A-Za-z0-9-]+)/editusers$ editusers.php?project=$1 [L,QSA]

#any project map (2)
RewriteRule ^([A-Za-z0-9-]+)/([^/]+)$ view.php?project=$1&map=$2 [L,QSA]

#any project, any map, edit
RewriteRule ^([A-Za-z0-9-]+)/([^/]+)/edit$ edit.php?project=$1&map=$2 [L,QSA]

#root rules
RewriteRule ^login$ auth.php?action=login [L,QSA]

#project info
RewriteRule ^([A-Za-z0-9-]+)$ info.php?project=$1 [L,QSA]

Everything works as we would like, but all requests to /backend/*.php are redirected to view.php?project=backend&map=... I
rearrange the lines
#any project map (2)
RewriteRule ^([A-Za-z0-9-]+)/([^/]+)$ view.php?project=$1&map=$2 [L,QSA]

#project settings (1)
RewriteRule ^([A-Za-z0-9-]+)/editusers$ editusers.php?project=$1 [L,QSA]

the behavior changes to the diametrically opposite:
/project/editusers turns into view.php?project=project&map=editusers
I understand that most likely everything works correctly (that is, it works as it was written), but how to defeat it?
I want all requests to /backend/*.php to be directed to the /backend/*.php files, and not just anywhere. (in different, similar variations) added to the block of air conditioners (before, after, between, it doesn’t matter) does not change anything at all. At the same time js'ki and css'ki from fronend/*.* are loaded absolutely normally. And, yes, I am 100% sure that the requested file in /backend/ exists! (after all, in one version it is normally requested, but in the other it is not!)
RewriteCond %{REQUEST_URI} !^/backend/
The third day already about the monitor I fight. RTFM did, Google read, tortured colleagues.
CHADNT?
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arris, 2015-09-06
@Arris

As a crutch, I had to make a temporary solution:
But I still have hope that someone knows the voodoo modrewright.

S
ShamblerR, 2015-09-08
@ShamblerR

Maybe I'm dumb but what's stopping you?

RewriteCond %{REQUEST_URI} !^/backend/*\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9-]+)/([^/]+)$ view.php?project=$1&map=$2 [L,QSA]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question