Trying to redirect this always works:
RewriteRule ^user/(.*) view_channel.php?user=$1 [nc]
The problem, trying to redirect the statement below alone works but when combined with the above statement it doesn't work (the result was a blank page):
RewriteRule ^user/videos/(.*) user_videos.php?user=$1 [nc]
More details about .htaccess:
Options All -Indexes
FileETag MTime Size
Options +FollowSymlinks -MultiViews
RewriteEngine on
<FilesMatch "\.(db|inc|tmpl|h|ihtml|sql|ini|configuration|config|class|bin|spd|theme|module|cfg|cpl|tmp|log|err|inc.php|class.php)$">
order allow,deny
satisfy all
</FilesMatch>
What am I doing wrong?
The rules are not mutually incompatible. Nor are they final. Change them like this:
RewriteRule ^user/([^/]+) view_channel.php?user=$1 [NC,L]
RewriteRule ^user/videos/([^/]+) user_videos.php?user=$1 [NC,L]
[^/]+
matches one or more character that is not a /
. This ensures that the first rule cannot match the second pattern, which it did with the .*
, as that matches any characters, including /
of course.
It is because your regex ^user/(.*)
also matches a URI like /user/videos/something
.
Have your rules like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^user/videos/([^/]+)/?$ user_videos.php?user=$1 [L,NC,QSA]
RewriteRule ^user/([^/]+)/?$ view_channel.php?user=$1 [L,QSA,NC]
第二个RewriteRule
语句与已经重写的url相匹配。
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.