我在.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重定向到子文件夹
发布评论