.htaccess重定向到子文件夹

编程入门 行业动态 更新时间:2024-10-22 02:48:12
本文介绍了.htaccess重定向到子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在.htacess重定向URL到子文件夹(子目录)时遇到问题. 我的文件夹结构就像.我在根文件夹web和sales中有两个目录.

i having problem with .htacess redirect URL's to sub-folders (sub-directory). My Folder Structure was like. i had two directories in my root folder web and sales.

目录1 -web/4.5, 目录2 -sales/2.5

Directory 1 - web/4.5 , Directory 2 - sales/2.5

我的主要URL网站就像 beta.example

And my main URL site was like http ://beta.example

当用户点击根URL( beta.example )时,它应该重定向到子文件夹名称 web/4.5 ,为此我编写了代码它正在工作.代码就像.

when user hits the root URL (http ://beta.example) it should redirect to sub-folder name web/4.5 for this i wrote code and it was working.the code was like.

RewriteEngine On RewriteCond %{HTTP_HOST} ^beta.example\$ RewriteCond %{REQUEST_URI} !^/web/4.5 RewriteRule (.*) /web/4.5/$1

上面的代码有效,但是, 当用户点击根URL( beta.example/sales/)时,应重定向至子文件夹 sales/2.5 ,为此我编写了代码并它不起作用.代码就像.

the above code was working but, when user hits the root URL (http ://beta.example/sales/) it should redirect to sub-folder sales/2.5 for this i wrote code and it was not working.the code was like.

RewriteEngine On RewriteRule ^sales/(.*) sales/2.5/$1 RewriteCond %{HTTP_HOST} ^beta.example\$ RewriteCond %{REQUEST_URI} !^/web/4.5 RewriteRule (.*) /web/4.5/$1

它不起作用,转到 web/4.5/sales/2.5/,实际上转到/sales/2.5/

it was not working ,it goes to web/4.5/sales/2.5/ ,actually it goes to /sales/2.5/

    --
推荐答案

此处

RewriteEngine On RewriteCond %{REQUEST_URI} !^/sales/2.5 RewriteRule ^sales/(.*) /sales/2.5/$1 [L] RewriteCond %{REQUEST_URI} !^/sales/2.5 RewriteCond %{REQUEST_URI} !^/web/4.5 RewriteRule (.*) /web/4.5/$1

[L]停止以下重定向过程.

The [L] stops following redirect processes.

更多推荐

.htaccess重定向到子文件夹

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

发布评论

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

>www.elefans.com

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