以下 RewriteRule 可以正常工作
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301]
直到我把这个放在正下方
RewriteRule ^([a-z0-9]+)/$ /profile/company-profile.php?cname=$1 [NC,L]
现在每个domain.com/something-here都会转到company-profile.php
我该如何解决这个问题?
首先,domain.com/login会将您带到登录文件夹的index.php。
当我输入第二个 RewriteRule 时,如果我再次写入 domain.com/login ,它会(在后台)显示 company-profile.php?cname=login
最佳答案
我建议使用这个:
RewriteEngine On
RewriteBase /
# redirect company specific request
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9\-_]+)/?$ profile/company-profile.php?cname=$1 [NC,L]
# redirect all others
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/?$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301]
关于php - 修改 RewriteRule,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8206909/