2017-09-29 111 views
0

舊的URL錯誤404找不到網頁

http://www.mywebsite.in/index.php/view-college?college_name=Suvidya+Institute+of+Technology%20(engineering) 

新的URL

http://mywebsite.in/college/Suvidya%20Institute%20of%20Technology%20(engineering) 

.htaccess文件

ErrorDocument 404 /404.php 

Redirect 301 view-college.php?college_name=Suvidya+Institute+of+Technology%20(engineering) http://mywebsite.in 

Options +FollowSymlinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^mywebsite\.in 

我想我的舊網址重定向到我的主頁,因爲我有將我的核心php項目移到codeigniter中。在這個htaccess文件中顯示我找不到404錯誤頁面。可能是我的htaccess文件不正確。那麼,我該如何解決這個問題?請幫助我。

謝謝

+0

任何人可以幫助我請 – omkara

回答

0

對不起上述answer.From我的研究,現在,在重定向我們不能使用查詢字符串,所以我們需要使用RewriteEngine敘述

RewriteEngine On 
    RewriteCond %{QUERY_STRING} college_name=Suvidya\+Institute\+of\+Technology%20\(engineering\) 
    RewriteRule (.*) http://mywebsite.in? [R=302,L] 

如果RewriteEngine On已經寫入您的.htaccess文件不要再寫入,只寫下面兩行

RewriteCond %{QUERY_STRING} college_name=Suvidya\+Institute\+of\+Technology%20\(engineering\) 
    RewriteRule (.*) http://mywebsite.in? [R=302,L] 

我已經執行上面的代碼,它工作正常

+0

謝謝@Vinod sai。有用。 :) – omkara

-1

您需要添加一個「/」前視圖college.php。即,從

Redirect 301 view-college.php?college_name=Suvidya+Institute+of+Technology%20(engineering) http://mywebsite.in 

更改您的重定向行

Redirect 301 /view-college.php?college_name=Suvidya+Institute+of+Technology%20(engineering) http://mywebsite.in 
+0

我已經使用這個它不工作@Vinod賽 – omkara

+0

一些服務器犯規允許相對URL的所以要儘量添加全路徑的重定向網址。例如,如果你在名爲college的文件夾中有view-college.php,那麼你的代碼應該是'Redirect 301 /colleges/view-college.php?college_name=Suvidya+Institute+of+Technology%20(engineering)http://mywebsite.in' –

+0

看看我的編輯代碼我已經顯示我的新舊網址 – omkara