我正在使用codeignator,并且必须重定向URL。我有两个网址,如下所示:
https://example.com/contact-us/
https://example.com/about-us/who-we-are/
我在codeignator项目中没有任何contact
和about-us/who-we-are/
控制器名称或视图。
让我们谈谈存在的URL
我正在从URL中删除index.php和控制器名称。
所以我的旧网址是
https://example.com/index.php/Menu_control/aboutus
现在新的URL是
https://example.com/aboutus
//$route['(:any)'] = 'Menu_control/$1';//remove the controller name
现在,当用户输入URL https://example.com/contact-us/
时,应在https://example.com/aboutus/
上重定向
与我在第二个URL https://example.com/about-us/who-we-are/
上重定向到https://example.com/services/
的情况
我在.htaccess中尝试了一些代码,但不适用于我。
Redirect 301 "https://example.com/contact/" "https://example.com/aboutus/"
在这个问题上您能帮我吗?
答案 0 :(得分:0)
在RewriteBase /文件解决问题后,在.htaccess的顶部添加RewriteRrule。
sqoop eval (generic-args) (eval-args)
答案 1 :(得分:0)
最后我找到了答案。我不知道这是不是最好,但解决了我的问题。
我在.htaccess中添加了代码
RewriteRule ^contact-us/ https://example.com/aboutus [R=301,L]
RewriteRule ^about-us/who-we-are/ https://example.com/services/ [R=301,L]
当用户输入URL https://example.com/contact-us/
时,它将在https://example.com/aboutus
上重定向
答案 2 :(得分:0)
Apache Redirect
directive应该可以工作。我认为使用它的失败尝试是由于语法错误。第二个参数(状态后的一个)必须是 URL路径,而不是 URL 。细微但重要的区别。
在.htaccess
中尝试这些
Redirect 301 "/contact" "https://example.com/aboutus"
Redirect 301 "/about-us/who-we-are" "https://example.com/services"
而且,我确定您知道,但是我不得不指出,请确保启用“别名”模块(mod_alias)。