旧网址
http://www.mywebsite.in/index.php/view-college?college_name=Suvidya+Institute+of+Technology%20(engineering)
新网址
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 :(得分:0)
对不起上面的答案。从我现在的研究来看,在重定向中我们不能使用查询字符串,所以我们需要使用RewriteEngine
RewriteEngine On
RewriteCond %{QUERY_STRING} college_name=Suvidya\+Institute\+of\+Technology%20\(engineering\)
RewriteRule (.*) http://mywebsite.in? [R=302,L]
如果已经在.htaccess文件中写入了RewriteEngine On,请不要再次写入,只写下面两行
RewriteCond %{QUERY_STRING} college_name=Suvidya\+Institute\+of\+Technology%20\(engineering\)
RewriteRule (.*) http://mywebsite.in? [R=302,L]
我已执行上述代码并且工作正常
答案 1 :(得分:-1)
您需要在view-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