我的。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>
我希望能够重定向一个URL,看起来像这样..
https://sub.domain.com/ZTHF76
……
https://www.domain.com/members/invite/ZTHF76
但是我得到了
https://www.domain.com/members/invite/index.php
我需要保留第一条规则,从应用程序其余部分的URI中删除index.php
。
你应该重新排序你的规则,并在重写之前保留重定向规则:
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]