htaccess mod_rewrite 主机名 [英] htaccess mod_rewrite hostname

查看:30
本文介绍了htaccess mod_rewrite 主机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果不匹配,我如何将域 url 重写为特定域名..

How can i rewrite the domain url to a specific domain name if it didnt match it ..

假设我希望它只匹配 example.com并且访问者来自服务器 ip (http://127.0.0.1/something/else) 或来自另一个域 (http://domain.com/something/else)

Let's say i want it to only match example.com and the visitor came from server ip (http://127.0.0.1/something/else) OR came from another domain (http://domain.com/something/else)

我怎样才能重写域名并保留所有其他参数,只是域名到 example.com(结果应该是:http://example.com/somthing/else )

how can i rewrite the domain name and keep all the other parameters, just domain name to example.com ( result should be : http://example.com/somthing/else )

推荐答案

尝试将这些规则添加到文档根目录中的 htaccess 文件中:

Try adding these rules to the htaccess file in your document root:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www.)?example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R]

这篇关于htaccess mod_rewrite 主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆