具有.htaccess的两个不同根目录
我在同一个目录下有这些文件夹具有.htaccess的两个不同根目录,.htaccess,redirect,.htaccess,Redirect,我在同一个目录下有这些文件夹 /front /backend 我想重定向到/front文件夹(这是最简单的部分) 并重定向到/backend文件夹 我的问题是,如果我尝试做以下事情: RewriteCond %{HTTP_HOST} ^beta\.domain\.com$ RewriteCond %{REQUEST_URI} !^/front/ RewriteRule (.*) /front/$1 这个url http://beta.domain.com/back被重定向到/front/ba
/front
/backend
我想重定向到/front文件夹(这是最简单的部分)
并重定向到/backend文件夹
我的问题是,如果我尝试做以下事情:
RewriteCond %{HTTP_HOST} ^beta\.domain\.com$
RewriteCond %{REQUEST_URI} !^/front/
RewriteRule (.*) /front/$1
这个url http://beta.domain.com/back被重定向到/front/back,我不想要这个
我需要类似“如果url中有^domain.com/back,则根目录为/backend,否则为/front”
多谢各位
RewriteEngine On
RewriteCond %{HTTP_HOST} ^beta\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/front [NC]
RewriteCond %{REQUEST_URI} !^/back [NC]
RewriteCond %{REQUEST_URI} !^/favourites [NC]
RewriteRule ^(.*)$ /front/$1 [L]
RewriteCond %{HTTP_HOST} ^beta\.domain\.com$ [NC]
RewriteRule ^back/(.*)$ /backend/$1 [L]
RewriteRule ^favourites/?$ templates/favourites.php [NC,L]
这对你有用吗?可能有一种方法可以组合这两个块,但这很简单
更新:为“Favorites”特殊处理添加排除项它的工作原理,但我也有这行代码重写规则^Favorites$templates/favorites.php[L,NC],如果我尝试访问beta.domain.com/favorites,它会说“未找到请求的URL/front/favoritos在此服务器上未找到”。(/templates is in/front/templates)然后添加
RewriteCond%{REQUEST\u URI}^/第一组中的收藏夹[NC]
(for/front),第二组中的重写规则^favorites/?$templates/favorites.php[NC,L]
。看到模式了吗?