php - 想要使 http ://test. domain.tld/go 到 http ://domain. tld/test

标签 php .htaccess redirect

<分区>

Possible Duplicate:
Internal subdomain to folder redirect

我希望它是自动的,因为我正在为 URL 缩短器制作它。我知道如何手动制作每一个,但这不能满足我的需要。我知道我需要 .htaccess 中的一些东西,但我对此一点经验都没有。有谁知道要添加什么才能使它正常工作?

最佳答案

您可以使用 .htaccess 中的 apache mod_rewrite 来完成此操作,如下所示:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^\.]+).domain.tld$ [NC]
RewriteRule . http://domain.tld/%1 [R=301,L]

关于php - 想要使 http ://test. domain.tld/go 到 http ://domain. tld/test,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13433414/

相关文章:

php - QHttpMultiPart 上传多个文件

php - 如何阻止对除内部页面之外的文件夹的访问

Apache 重定向网址

php - 是否可以使用 PHP 在网页中显示 RTF 文件?

php - 在 php 中连接到 MySQL 数据库时遇到问题

php - 在没有 ssl 的情况下登录时不显示 Wp 管理栏

.htaccess - 使用 Mod_Rewrite 去除扩展

.htaccess ModRewrite 带 2 个参数

php - htaccess重定向问题

linux - Bash 脚本 - 将子脚本 stderr 重定向到父脚本的 stdout