如何屏蔽网站中的URL? [英] How to mask a URL in a website?
问题描述
我要屏蔽 URL。我有一个我不希望人们在我的网站上了解的子域。所以我需要帮助的是这个
I want to "mask" a URL. I have a subdomain that I do not want people to know about on my website. So what I am needing help with is this:
我的网站是:www.example.com
My website is: www.example.com
I有一个子域:sub.example.com/test.php
I have a subdomain: sub.example.com/test.php
当某人单击指向sub.example.com/test.php的链接时,我没有希望 sub.example.com/test.php显示在网址栏中。我希望显示www.example.com。
When someone clicks on a link that points to sub.example.com/test.php, I do not want "sub.example.com/test.php" to show in the url bar. I would like for www.example.com to show instead.
推荐答案
当您要链接到时sub.example.com/test.php
,将链接更改为其他内容,例如 www.example.com/sub/test.php
或的东西。然后在 www.example.com
的文档根目录的.htaccess文件中添加以下内容:
When you want to link to sub.example.com/test.php
, change the link to something else, like www.example.com/sub/test.php
or something. Then in your .htaccess file in the document root for www.example.com
add this:
RewriteEngine On
RewriteRule ^sub/(.*)$ http://sub.example.com/$1 [L,P]
这将在内部将对 www.example.com/sub /
的任何请求代理到 sub.example.com
。因此,当有人请求 http://www.example.com/sub/path/file.html ,他们实际上会得到 http://sub.example.com/path/file.html ,但其URL地址栏仍具有example.com URL。您只需要确保将所有sub.example.com链接更改为example.com/sub /
This will internally proxy any request for www.example.com/sub/
to sub.example.com
. So when someone requests http://www.example.com/sub/path/file.html, they really get http://sub.example.com/path/file.html except their URL address bar still has the example.com URL. You just need to make sure to change all of your links to sub.example.com to example.com/sub/
这篇关于如何屏蔽网站中的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!