重定向到目录并隐藏 url

发布于 2025-01-01 04:49:06 字数 1459 浏览 0 评论 0原文

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

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

发布评论

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

评论(2

九命猫 2025-01-08 04:49:06

您可以尝试这样的通用规则:

RewriteCond %{HTTP_HOST} ^(www\.)?((?!www)[^\.]*)\.cheapantivirus\.com$ [NC] 
RewriteRule ^$ http://www.cheapantivirus.com/blog/index.html [P,L]

请注意,这需要在您的 Apache 中启用 mod_proxy。

这将代理:

www.blog.cheapantivirus.com to www.cheapantivirus.com/blog/index.html
www.blog.cheapantivirus.com to www.cheapantivirus.com/blog/index.html
www.subdomain.cheapantivirus.com to www.cheapantivirus.com/blog/index.html
www.foo.cheapantivirus.com to www.cheapantivirus.com/blog/index.html

由于它使用 P 标志,因此不会导致您的浏览器 URL 发生更改。

You can try a generic rule like this:

RewriteCond %{HTTP_HOST} ^(www\.)?((?!www)[^\.]*)\.cheapantivirus\.com$ [NC] 
RewriteRule ^$ http://www.cheapantivirus.com/blog/index.html [P,L]

Note that this requires mod_proxy enabled in your Apache.

This will proxy:

www.blog.cheapantivirus.com to www.cheapantivirus.com/blog/index.html
www.blog.cheapantivirus.com to www.cheapantivirus.com/blog/index.html
www.subdomain.cheapantivirus.com to www.cheapantivirus.com/blog/index.html
www.foo.cheapantivirus.com to www.cheapantivirus.com/blog/index.html

Since it is using P flag therefore it won't cause your browser URL to change.

情绪 2025-01-08 04:49:06

如何将用户重定向到 www.blog.myname.com/blog/index.html,但地址栏上的 URL 被屏蔽,仅显示 www.blog.myname.com

RewriteCond %{HTTP_HOST} ^www\.blog\.myname\.com$ [NC] 
RewriteRule ^$ blog/index.html [L]

如果您想发送来自 www.blog.myname 的所有请求, .com 到 www.blog.myname.com/blog 使用此替代

RewriteCond %{HTTP_HOST} ^www\.blog\.myname\.com$ [NC] 
#not already /blog/
RewriteCond %{REQUEST_URI}  !^/blog/[NC] 
#not an existing file or directory
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ blog%{REQUEST_URI} [L]

将以下内容添加到 .htaccess 文件中您已有的重定向规则之后

How could I redirect user to www.blog.myname.com/blog/index.html but URL at the address bar is masked and only showing www.blog.myname.com

RewriteCond %{HTTP_HOST} ^www\.blog\.myname\.com$ [NC] 
RewriteRule ^$ blog/index.html [L]

If you want to send all requests from www.blog.myname.com to www.blog.myname.com/blog use this instead

RewriteCond %{HTTP_HOST} ^www\.blog\.myname\.com$ [NC] 
#not already /blog/
RewriteCond %{REQUEST_URI}  !^/blog/[NC] 
#not an existing file or directory
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ blog%{REQUEST_URI} [L]

Add the following to the .htaccess file after the redirect rule you already have

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文