htaccess的mod_rewrite的主机名 [英] htaccess mod_rewrite hostname

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

问题描述

如何改写域名网址到一个特定的域名,如果它没有与之相匹配的。

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天全站免登陆