重定向网站根子目录根子、重定向、目录、网站

由网友(暧昧、就是上床的前奏)分享简介:我如何可以重定向将Web根目录的所有请求到另一个文件夹(如公共/)?How can I redirect all requests going to web root to another folder (e.g. public/)?我已经尝试过这个(的.htaccess的Web根目录):I've already...

我如何可以重定向将Web根目录的所有请求到另一个文件夹(如公共/)?

How can I redirect all requests going to web root to another folder (e.g. public/)?

我已经尝试过这个(的.htaccess的Web根目录):

I've already tried this (contents of .htaccess in web root):

RewriteEngine on
RewriteRule ^(.*)$ public/$1

但现在我有地址重复的内容: address.tld / 和 address.tld /公/

But now I have duplicate content for addresses: address.tld/ and address.tld/public/

我想重定向 address.tld /公/ 为 address.tld / ,所以不会有任何重复,但我不知道如何做到这一点,而不是进入重定向循环......

I would like to redirect address.tld/public/ to address.tld/, so there won't be any duplicates, but I just don't know how to do it and not get into redirecting cycle...

推荐答案

请尝试以下规则:

RewriteCond %{THE_REQUEST} ^GET /public/
RewriteRule ^public/(.*) /$1 [L,R=301]
RewriteRule !^public/ public%{REQUEST_URI} [L]
阅读全文

相关推荐

最新文章