【发布时间】:2017-12-30 21:23:55
【问题描述】:
我已将所有内容从旧站点移动到新站点,现在我想将所有页面从旧站点 301 重定向到具有相同 URL 的新站点。
例子:
http://www.oldsite.net/en/newspage.html到http://www.newsite.com/en/newspage.htmlhttp://www.oldsite.net/en/aboutus.html到http://www.newsite.com/en/about.html
这是我的.htaccess:
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTP_HOST} ^www\.olddoamin\.net$ [NC]
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L]
这会重定向新网站同一页面上的所有页面,
但新站点在重定向后的 URL 中有 index.php?。例如:
http://www.newsite.com/index.php?/en/about.html
网站是用 codeigniter 开发的。
有人知道为什么会这样吗?
【问题讨论】:
-
您的
$config['index_page']值是多少? -
$config['index_page'] = ' ';
-
只需将
.htaccess的最后两行移至RewriteEngine On行的顶部或下方即可。 -
谢谢anubhava,但它不起作用:(
标签: .htaccess codeigniter