i have a htaccess rule that remove .php
extension:
`RewriteEngine On
ErrorDocument 403 "Page not exist"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]`
the htaccess rule below redirects to stream.php
file:
`RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /core/musicbox/stream/?tag=$1 [NC,L,QSA]`
Both rule works individually, but when combined,the rule placed below does not work.
You have the same conditions twice:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Which means:
!-f
: File %{REQUEST_FILENAME}
doesn't exist. !-d
: Directory %{REQUEST_FILENAME}
doesn't exist. If both are true and the next one (in the first set of rules) is also true:
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
Then the next rule will do a 301
redirect ( R=301
) and stop processing rules ( L
).
RewriteRule (.*)$ /$1/ [R=301,L]
Actually, maybe there's a missing ^
in there. It should be:
RewriteRule ^(.*)$ /$1/ [R=301,L]
Anyway, that means that the second set of conditions and the subsequent rule won't be reached:
RewriteRule ^(.*)$ /core/musicbox/stream/?tag=$1 [NC,L,QSA]
Probably you don't need those first R=301
and L
flag. I think this is how it should look like:
RewriteEngine On
ErrorDocument 403 "Page not exist"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ /$1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /core/musicbox/stream/?tag=$1 [NC,L,QSA]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.