htaccess 301重定向问题 [英] htaccess 301 redirection issue
本文介绍了htaccess 301重定向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
关于301重定向,如何从一个URL重定向到另一个?
Regarding 301 redirection, how can I redirect from one URL to another?
From: http://www.xyz.com/abc.php%0D%0A
To: only url and abc.php
使用.htaccess无效.
Using .htaccess it does not working.
Redirect 301 /abc.php%0D%0A http://www.xyz.com/abc.php
请咨询.有可能吗?
推荐答案
您需要使用支持正则表达式的RedirectMatch
:
You need to use RedirectMatch
that supports regex:
RedirectMatch 301 ^/(abc\.php).*$ /$1
或者您也可以使用mod_rewrite
.
通过httpd.conf
启用mod_rewrite
和.htaccess
,然后将此代码放入您的DOCUMENT_ROOT/.htaccess
文件:
Enable mod_rewrite
and .htaccess
through httpd.conf
and then put this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteRule ^(abc\.php).*$ /$1 [L,NC,R=301]
这篇关于htaccess 301重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文