.htaccess - 将文件夹重写为子域

标签 .htaccess rewrite subdomain subdirectory

我想在此之后重写所有地址
http://www.mydomain.com/questions/*
对此
http://*.mydomain.com/
例如:
http://www.mydomain.com/questions/example
http://example.mydomain.com/
谁能帮我解决这个问题!?
谢谢

最佳答案

给你。

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^.mydomain\.com$
RewriteRule ^questions/([^/]+)/?$ http://$1.mydomain.com/ [NC,R=301,L]

将其插入到您的 .htaccess 文件中,您就可以开始了。 :)

关于.htaccess - 将文件夹重写为子域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18463736/

相关文章:

.htaccess 不工作

redirect - 我如何在 NgInX 中将带有查询字符串的 url 重定向到没有查询字符串的 url?

internet-explorer - 使用 htaccess 重定向 IE 6、7 和 8 用户

.htaccess - 最佳实践 : 301 Redirect HTTP to HTTPS (Standard Domain)

nginx/index.html 到/重写

.htaccess,重定向不存在,除了少数 URL 重写

redirect - 检测语言并重定向到 Symfony 上的子域

apache - 如何使用 JBoss(或 Apache Tomcat)将 ip 和端口绑定(bind)到子域

asp.net - 让 Visual Studios 使用子域?

php - 请求超出了 10 个内部重定向的限制