douzhuo5671 2014-04-17 06:40
浏览 117
已采纳

.htaccess重定向到子文件夹

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.

Root

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

And my main URL site was like 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.

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.

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/

    -

  • 写回答

1条回答 默认 最新

  • dongyuan9109 2014-04-17 06:50
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助