的.htaccess重写重定向根URL子目录 [英] .htaccess rewrite to redirect root URL to subdirectory

查看:620
本文介绍了的.htaccess重写重定向根URL子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图让

www.example.com

要直接去

www.example.com/store

我已经试过了code和没有工作的多个位。请帮帮忙!

I have tried multiple bits of code and none work. Please help!

我已经试过什么:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^(.+)\www.example\.com$
RewriteRule ^/(.*)$ /samle/%1/$1 [L]

我是什么做错了吗?

What am I doing wrong?

推荐答案

您可以使用使用重写规则的 ^ $ 以重新present的根源,重写你的/存储目录,像这样的:

You can use a rewrite rule that uses ^$ to represent the root and rewrite that to your /store directory, like this:

RewriteEngine On
RewriteRule ^$ /store [L]

这篇关于的.htaccess重写重定向根URL子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆