简体   繁体   English

htaccess重定向到根域

[英]htaccess redirect to root domain

I have domain name with subdirectory which i want to redirect to root folder. 我的域名带有要重定向到根文件夹的子目录。 For example when the users visit here example.com/contact , i would like to redirect to example.com . 例如,当用户访问此处example.com/contact ,我想重定向到example.com Currently are my htaccess code to redirect example.com to www.example.com . 目前是我的htaccess代码,用于将example.com重定向到www.example.com

# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Try this: 尝试这个:

RewriteEngine On
RewriteBase /

RewriteRule ^subdir/(.*)$ http://www.example.com/$1 [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM