htaccess的从根重定向到子文件夹,然后屏蔽网址是什么?屏蔽、文件夹、重定向、网址

2023-09-02 09:45:51 作者:成为你的例外

两件事情:

首先 - 我有位于一个文件夹命名为V2网站的第2版,我想重定向任何流量不是V2文件夹的孩子,www.example.com/~~V V2

旧址位于根是在iWeb中创建和拥有子文件夹和子子文件夹了很多。

所以:

www.example.com/v2 =新网站

www.example.com/Page.html

www.example.com/category/Page.html

ww.example.com/category/subcategory/Page.html =什么,我需要重定向所有的通用例子。

第二,然后我不知道这是可能的,我想隐藏/ V2 / URL中,让游客只会看到www.example.com/page即使他们实际上在www.example.com/v2/page

链接很难coded到v2的文件夹,像这样< A HREF = V2 / contact.html >

任何帮助最AP preciated。我花了几个小时试图弄清楚这一点,但我只是刚刚了解htaccess以及定期EX pressions,和我完全糊涂了。

太感谢了!

解决方案

 的RewriteCond%{REQUEST_URI}!^ V2 /
重写规则^(。*)V2 / $ 1 [L]
 

Two things:

金山卫士如何屏蔽网站

Firstly - I have version 2 of a website located in a folder named v2, and I want to redirect any traffic that is NOT a child of the v2 folder, to www.example.com/v2

The old site located in the root was created in iWeb and has a LOT of subfolders and sub-subfolders.

So:

www.example.com/v2 = New site

www.example.com/Page.html

www.example.com/category/Page.html

ww.example.com/category/subcategory/Page.html = All generic examples of what I need to redirect.

Secondly, and I don't know if this is possible, I want to hide /v2/ in the URL, so that visitors will just see www.example.com/page even though they are actually on www.example.com/v2/page

Links are hardcoded to the v2 folder, like so <a href="v2/contact.html">

Any help is MOST appreciated. I've spent hours trying to figure this out, but I'm only just learning about htaccess and regular expressions, and am totally confused.

Thanks so much!

解决方案

RewriteCond %{REQUEST_URI} !^v2/
RewriteRule ^(.*)$ v2/$1 [L]