将 url 从子目录重写为子域

发布于 2024-10-08 02:04:41 字数 142 浏览 0 评论 0原文

如何使用 .htaccess 重定向 url?

实际网址是 www.mywebsite.com/index.php/user/john

需要转换为 john.mywebsite.com/

How to redirect the url using .htaccess?

Actual url is www.mywebsite.com/index.php/user/john

is need to convert as john.mywebsite.com/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

客…行舟 2024-10-15 02:04:41

.htaccess 中尝试以下代码:

Options +FollowSymLinks
RewriteEngine on
RewriteEngine On
RewriteRule ^index.php/(.*)/(.*) $2.mywebsite.com/

Try this code in .htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteEngine On
RewriteRule ^index.php/(.*)/(.*) $2.mywebsite.com/
情愿 2024-10-15 02:04:41

如果您有通配符 Dns,请联系您的主机提供商/管理员。并向线路请求
服务器配置文件上的 *.yourdomain.com。

您可以在 htaccess 文件中编写自己的内容,如下所示,

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourdomain.com
RewriteCond %{HTTP_HOST} ([^.]+)\.yourdomain.com
RewriteRule ^(.*)$ /path_to_your_site/subdoamin.php?url=%1

If you have wildcard Dns, contact your host provider/adminisrator. And request to the line
*.yourdomain.com on server configuration file.

You can write your self on your htaccess file as following,

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourdomain.com
RewriteCond %{HTTP_HOST} ([^.]+)\.yourdomain.com
RewriteRule ^(.*)$ /path_to_your_site/subdoamin.php?url=%1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文