简体   繁体   English

使用.htaccess更改网址

[英]Change a url using .htaccess

I want to change my URL totally, for example I have a URL like this: 我想完全更改我的URL,例如,我有一个这样的URL:

www.myurl.org

I require: 我要求:

www.change.com  

Whenever anyone open: 只要有人打开:

www.myurl.org

Then open my site and change URL in URL bar, How can I do that? 然后打开我的网站并在URL栏中更改URL,我该怎么做?

Edit: I do not want the user to be redirected to that site. 编辑:我不希望用户被重定向到该站点。 I want the url in the address bar to be changed to www.change.com while the user is actually on www.myurl.org . 我希望用户实际上在www.myurl.org上时,地址栏中的url更改为www.change.com

Here is your answer: Please believe me.(-; 这是您的答案:请相信我。(-;

You can't do it in internet. 您无法在互联网上做到这一点。 Maybe you can do it on your local network. 也许您可以在本地网络上进行操作。

Please think if it was possible. 请考虑是否可能。 Then how we could trust internet and websites? 那我们如何才能信任互联网和网站呢?

Any hostname that is directed to your app will be re-written to use change.com. 定向到您应用的任何主机名都将被重写以使用change.com。 The RewriteCond allows requests to change.com to pass through, and and the RewriteRule rewrites all other URLs. RewriteCond允许请求change.com通过,并且RewriteRule重写所有其他URL。

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

Oh course, you must have mod_rewrite enabled. 当然,您必须启用了mod_rewrite And It may or may not be allowed in .htaccess files depending on your Apache Configuration. 而且,根据您的Apache配置,.htaccess文件中可能允许也可能不允许使用它。

Here is the Apache Documentation on the topic. 这是关于该主题的Apache文档

您可以使用旧的iframe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM