簡體   English   中英

301將舊網址重定向到新網址-Codeigniter

[英]301 redirect for old urls to new urls - codeigniter

我希望在這里得到一些幫助。 我們有一個靜態的php網站已有幾年了,最近我們在codeigniter中重新設計了該網站。 現在,在重新設計之后,我們的許多網址已更改,例如

example.com/about_us成為example.com/about
example.com/programs-list變為example.com/programs
等等。

我們的舊網址拋出404錯誤。 我們要求開發人員為舊的網址添加301重定向,以便我們的SEO程序完全由Google傳遞給新的網址。 開發人員說他已經使用routes.php文件進行了重定向(並且正在工作),但是我不確定這是否真的是301重定向。 在大多數情況下,我使用htaccess文件添加了301重定向。 發生的事情是,現在當我們轉到鏈接example.com/about_us(這是舊的URL)時,它確實顯示了新頁面的內容(example.com/about),但地址欄中的URL仍然是示例.com / about_us。 我的理解是,如果我們添加301重定向,則只需將地址欄中的鏈接從example.com/about_us重定向到example.com/about。 目前,example.com / about和example.com/about_us兩個頁面均已加載。 這是正確的方法還是我們遺漏了一些東西。

感謝您的指導。

謝謝

這是我的htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
#  slashes.
# If your page resides at
#  http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
RewriteRule ^(about_us)\.php$ /about/$1 [R=301,NC,L,QSA]
</IfModule>

.htaccess重定向

對於相同的URL使用以下代碼

      Redirect 301 /oldfile.htm /newfile.htm

添加此代碼或在old-page.html目錄中創建新的.htaccess文件。 單個URL重定向從old-page.html永久重定向到new-page.html。 .htaccess:

       Redirect 301 /old-page.html http://www.example.com/new-page.html

整個域重定向

從所有域頁面永久重定向到newdomain.com。 .htaccess文件應位於舊網站的根目錄中。 .htaccess:

             Redirect 301 / http://www.newexample.com/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM