[英]How to redirect homepage to subfolder without changing URL (still keep www.example.com)
My current .htaccess
is in httpdocs. 我当前的.htaccess
位于httpdocs中。 How can I configure it to help domain point to subfolder is /vn/
我如何配置它以帮助域指向子文件夹为/vn/
and still keep: www.example.com
instead of www.example.com/vn/
并且仍然保留: www.example.com
而不是www.example.com/vn/
In .htaccess add these lines : 在.htaccess中,添加以下行:
RewriteEngine On
RewriteRule !^blog/ /blog%{REQUEST_URI} [L,R=301]
Or in some hosts : 或在某些主机中:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?YourDomainName.com$
RewriteRule ^(/)?$ blog [L]
Try the following near the top of your .htaccess
file in the document root: 在文档根目录中的.htaccess
文件顶部附近尝试以下操作:
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule (.*) /vn/$1 [L]
This internally rewrites all requests that hit the document root to the /vn/
subdirectory. 这会在内部将命中文档根目录的所有请求重写到/vn/
子目录中。 The RewriteCond
directive that checks against the REDIRECT_STATUS
environment variable ensures the request is only rewritten once - thus avoiding a rewrite loop. 检查REDIRECT_STATUS
环境变量的RewriteCond
指令可确保请求仅被重写一次-从而避免了重写循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.