php – 在CodeIgniter中有301重定向吗?问题
发布时间:2020-12-13 16:54:56 所属栏目:PHP教程 来源:网络整理
导读:Options +FollowSymlinksRewriteEngine onRewriteCond $1 !^(index.php|assets|uploads|tt|application/modules/.*/assets|resources|robots.txt|favicon.ico)RewriteRule ^(.*)$/index.php?/$1 [L] Redirect 301 /testurl /home/ 这是我的.htaccess文件,
Options +FollowSymlinks RewriteEngine on RewriteCond $1 !^(index.php|assets|uploads|tt|application/modules/.*/assets|resources|robots.txt|favicon.ico) RewriteRule ^(.*)$/index.php?/$1 [L] Redirect 301 /testurl /home/ 这是我的.htaccess文件,用于在我的CodeIgniter项目中检查301重定向. 301重定向工作正常,但问题在于URL.当我尝试…… http://parcmobilenew.eworkdemo.com/testurl …它会重定向到.htaccess中提到的主页,但它会在查询字符串中获取请求的URL,如下所示… http://parcmobilenew.eworkdemo.com/home?/testurl 如何在重定向时使.htaccess不这样做? 解决方法
>不要将重定向规则与mod_alias规则混合使用.
>在内部重写规则之前保留重定向规则. 您可以使用此代码: Options +FollowSymlinks RewriteEngine on RewriteRule ^testurl/?$/home/? [L,NC,R=301] RewriteCond $1 !^(index.php|assets|uploads|tt|application/modules/.*/assets|resources|robots.txt|favicon.ico) RewriteRule ^(.*)$/index.php?/$1 [L,QSA] 最好在新的浏览器中测试以避免旧的301缓存. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |