[英]htaccess non permanent redirect (301)
I'm trying to redirect every visitor that tries to enter my homepage (http://www.mysite.com/) to the Pub
directory (http://www.mysite.com/Pub/) 我正在尝试将所有尝试进入我的主页(http://www.mysite.com/)的访问者重定向到
Pub
目录(http://www.mysite.com/Pub/)
I want the url field to show http://www.mysite.com and not http://www.mysite.com/Pub/ 我希望url字段显示http://www.mysite.com而不是http://www.mysite.com/Pub/
I've tried this, but for some reason it doesn't work: 我已经尝试过了,但是由于某种原因它不起作用:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule / /Pub/
Thanks, 谢谢,
The answer is here: how to mask URL with htaccess? 答案在这里: 如何用htaccess屏蔽URL?
long story short - it's impossible to show http://www.mysite.com and not http://www.mysite.com/Pub/ . 长话短说-无法显示http://www.mysite.com而不显示http://www.mysite.com/Pub/ 。
Btw - you mean permanent redirect (301) or non permanent redirect (307)? 顺便说一句-您是说永久重定向(301)还是非永久重定向(307)?
Have your rule in .htacess like this: 在.htacess中设置您的规则,如下所示:
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteRule ^/?$ /Pub/ [L]
It is important to not use R
flag above so that its an internal redirect only without changing URL in the browser. 重要的是,不要在上方使用
R
标志,以便仅在不更改浏览器URL的情况下对其进行内部重定向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.