.htaccess 重定向/索引到/home
我当前在.htaccess中有此重写规则:.htaccess 重定向/索引到/home,.htaccess,mod-rewrite,redirect,url-rewriting,.htaccess,Mod Rewrite,Redirect,Url Rewriting,我当前在.htaccess中有此重写规则: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^index/([^/]*)/?$ /index.php?user=$1 [L] RewriteRule ^index/([^/]*)/([^/]*)$ /index.php?user=$1&sort=$2 [L] 我想将上面的/index重定向到/home,这里还需要考虑参数
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index/([^/]*)/?$ /index.php?user=$1 [L]
RewriteRule ^index/([^/]*)/([^/]*)$ /index.php?user=$1&sort=$2 [L]
我想将上面的
/index
重定向到/home
,这里还需要考虑参数。我如何才能做到这一点?尝试将规则更改为:
RewriteRule ^index/(.*)$ /home/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^home/([^/]*)/?$ /index.php?user=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^home/([^/]*)/([^/]*)$ /index.php?user=$1&sort=$2 [L]
@阿努巴瓦:是的。还有什么重定向?好的,希望下面的答案对你们有用。