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

编程入门 行业动态 更新时间:2024-10-13 06:16:08
本文介绍了htaccess的从根重定向到子文件夹,然后屏蔽网址是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

两件事情:

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

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

所以:

www.example/v2 =新网站

www.example/Page.html

www.example/category/Page.html

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

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

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

So:

www.example/v2 = New site

www.example/Page.html

www.example/category/Page.html

ww.example/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/page even though they are actually on www.example/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]

更多推荐

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

本文发布于:2023-10-31 13:32:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546232.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:屏蔽   文件夹   重定向   网址   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!