动态链接重定向至的.htaccess [英] Dynamic link redirect through .htaccess
问题描述
您好 我有一个像 HTTP链接://blog.a$c $ c.com / 2010/06 /混帐功能于窗口/ 现在我想将它重定向到 HTTP://一个code .COM / 2010/06 /混帐功能于窗户/
Hello I have a link like http://blog.acode.com/2010/06/git-in-windows/ now I want to redirect it to http://acode.com/2010/06/git-in-windows/
不过,2010/06 /混帐功能于窗口/这部分是不是一个静态的字符串,这可能会改变动态根据博客内容。
But "2010/06/git-in-windows/" this part is not a static string this might change depending on blog content dynamically.
如何做到这一点这样的.htaccess或PHP脚本或者两者兼而有之?
How to do this this .htaccess or php scripts or with both ?
感谢
推荐答案
这将移动重定向从 blog.a code.com
的任何链接 A code.com
同时保持URL路径不变。它基本上只是删除博客
的链接,并将其发送回。
This will move redirect any link from blog.acode.com
to acode.com
while keeping the path of the url intact. It basically just removes blog
from the link and sends it back.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog.acode.com$ [NC]
RewriteRule ^(.*)$ http://acode.com/$1 [R=301,L]
您应该用新域名更新博客软件配合这一行动。如果不这样做可能会引起不必要的混乱,这甚至不能被察觉。
You should complement this action by updating your blogging software with the new domain name. Failing to do so might lead to unnecessary complications, that could not even be noticed.
这篇关于动态链接重定向至的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!