简体   繁体   English

.htaccess重定向到子文件夹

[英].htaccess redirect to subfolders

i having problem with .htacess redirect URL's to sub-folders (sub-directory). 我在.htacess重定向URL到子文件夹(子目录)时遇到问题。 My Folder Structure was like. 我的文件夹结构就像。 i had two directories in my root folder web and sales. 我在根文件夹web和sales中有两个目录。

Root

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

And my main URL site was like http ://beta.example.com 我的主要URL站点就像http://beta.example.com

when user hits the root URL ( http ://beta.example.com ) it should redirect to sub-folder name web/4.5 for this i wrote code and it was working.the code was like. 当用户点击根URL( http://beta.example.com )时,它应该重定向到子文件夹名称web / 4.5 ,为此我编写了代码,它正在工作。代码就像。

RewriteEngine On

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

the above code was working but, when user hits the root URL ( http ://beta.example.com/sales/ ) it should redirect to sub-folder sales/2.5 for this i wrote code and it was not working.the code was like. 上面的代码可以正常工作,但是当用户点击根URL( http://beta.example.com/sales/ )时,我应该为此重定向到子文件夹sales / 2.5 ,因此我编写了代码,但无法正常工作。仿佛是。

RewriteEngine On

RewriteRule ^sales/(.*) sales/2.5/$1

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

it was not working ,it goes to web/4.5/sales/2.5/ ,actually it goes to /sales/2.5/ 它不起作用,转到web / 4.5 / sales / 2.5 / ,实际上转到/sales/2.5/

    - -

Here 这里

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

The [L] stops following redirect processes. [L]停止以下重定向过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM