Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 重定向/索引到/home_.htaccess_Mod Rewrite_Redirect_Url Rewriting - Fatal编程技术网

.htaccess 重定向/索引到/home

.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,这里还需要考虑参数

我当前在.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
,这里还需要考虑参数。我如何才能做到这一点?

尝试将规则更改为:

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]

@阿努巴瓦:是的。还有什么重定向?好的,希望下面的答案对你们有用。