简体   繁体   English

.htacess重定向

[英].htacess redirect

This may seem like a basic question, but I am not getting how to do it. 这似乎是一个基本问题,但我没有得到如何做到这一点。 Here is the Urls below. 以下是Urls。

Old Url : http://domain.com/index.php/items/view/item_name 旧网址: http//domain.com/index.php/items/view/item_name

New Url : http://domain.com/index.php/items/details/name/item_name 新网址: http//domain.com/index.php/items/details/name/item_name

How do I do a permanent redirect with this set of old and new Urls in htaccess? 如何在htaccess中使用这组旧的和新的Url进行永久重定向?

Put this code in your DOCUMENT_ROOT's .htaccess file: 将此代码放入DOCUMENT_ROOT的.htaccess文件中:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(items)/view/(.*)$ /$1/details/name/$2 [NC,L,R=301]

The following worked for me.... 以下为我工作....

upload a .htaccess file to the folder where ur file exists with the following data (it should be on a new line in the htaccess file) 使用以下数据将.htaccess文件上传到存在ur文件的文件夹(它应该位于htaccess文件中的新行)

redirect 301 /some_dir/oldpage.htm http://www.newdomain.com/newpage.htm

and from what i read somewhere when you need to do the same for a dynamic page you can use the following 根据我在某处需要为动态页面执行相同操作时,您可以使用以下内容

consider the page as 将页面视为

http://www.example.com/page.php?id=13

the redirect would be 重定向将是

RewriteEngine on 
RewriteCond %{QUERY_STRING} ^id=13$
RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]

here is what i got on googling for this http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm 这是我用谷歌搜索这个http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM