简体   繁体   English

如何在不更改URL的情况下将首页重定向到子文件夹(仍然保留www.example.com)

[英]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.

相关问题 使用htaccess将http://www.example.com/重定向到https://www.example.com/ - redirect http://www.example.com/ to https://www.example.com/ with htaccess 如何使用htaccess文件将“ http://www.example.com/pathquery-string=something”之类的网址重定向到错误页面 - How to redirect url like “http://www.example.com/pathquery-string=something” to error page using htaccess file 如何从Facebook通知重定向到:https://apps.facebook.com/appname/而不是:www.example.com? - How to redirect from Facebook notification not to: https://apps.facebook.com/appname/ but to: www.example.com? 如何将对www.example.com/admin的请求重定向到Zend中的其他模块 - How to redirect requests to www.example.com/admin to different module in Zend 如何将我的URL像www.example.com/profile.php?id=xyz转换为www.example.com/xyz? - How do i convert my URL's like www.example.com/profile.php?id=xyz into www.example.com/xyz? 在网址中显示用户名……www.example.com/JoeMason - displaying username in url… www.example.com/JoeMason 如何在像www.example.com/myname1或myname2这样的codeigniter中不带类的情况下动态传递参数 - How to pass parameter dynamic without class in codeigniter like www.example.com/myname1 or myname2 URL重写从www.example.com/blog/blog.php到www.example.com/blog/ - URL rewriting going from www.example.com/blog/blog.php to just www.example.com/blog/ 如何将网址从www.example.com/index.php?store=test重写为.htacess中的test.example.com或www.test.example.com - How to rewrite the url from www.example.com/index.php?store=test to test.example.com or www.test.example.com in .htacess 如何创建网址,例如www.example.com/EN/login - How to create URLs like www.example.com/EN/login
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM