我的.htaccess看起来像这样..
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/members/invite/$1 [R,L]
</IfModule>
我希望能够重定向看起来像这样的网址。
https://sub.domain.com/ZTHF76
为...
https://www.domain.com/members/invite/ZTHF76
但我得到了
https://www.domain.com/members/invite/index.php
我需要保留第一条规则,从应用程序其余部分的URI中删除index.php
。
对此的任何帮助都非常感激。
答案 0 :(得分:1)
您应重新排序规则并在重写规则之前保留重定向规则:
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/members/invite/$1 [L,R=302]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]