我用我的开发环境下重写(阿帕奇2),它工作得很好,我上传到我的生活环境(的Litespeed),它不再有效:(
为什么下面给出任何想法?
我使用的是P指令的mod_proxy这我的主机不支持。我怎样才能解决这个?
< IfModule mod_rewrite.c>
选项+的FollowSymLinks
RewriteEngine叙述上
的RewriteBase /
的RewriteCond $ 1 !(GIF |?JPE G | PNG)$ [NC]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{HTTP_HOST}!^ WWW 。 [NC]
的RewriteCond%{HTTP_HOST} ^([^。] +)。例如 .COM
重写规则^(。*)$ http://example.com/folder/%1/$1 [QSA,NC,P]
#删除的index.php
的RewriteCond $ 1 !(GIF |?JPE G | PNG)$ [NC]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php?/ $ 1 [L]
< / IfModule>
解决方案
我采取了不同的办法处理这一问题。显然,mod_proxy的方法是无效的,所以我用一些简单的code,确定子域和应用条件检查$子域是不是空字符串解决它在PHP。
$ url_parts =爆炸(,str_replace函数('',$ _ SERVER ['HTTP_HOST'])'。''example.com');
$子域=($ url_parts [0] =='')? $ url_parts [0]:'';
我只是重定向到正确的页面,一旦我知道有一个子域。
I'm using the following rewrite on my dev environment (Apache 2) and it works fine, I uploaded to my live environment (LiteSpeed) and it no longer works :(
Any ideas why given the following?
I'm using the "P" directive "mod_proxy" which my host doesn't support. How can I get around this?
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond $1 !.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^([^.]+).example.com
RewriteRule ^(.*)$ http://example.com/folder/%1/$1 [QSA,NC,P]
# Removes index.php
RewriteCond $1 !.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
解决方案
I took a different approach to this problem. Apparently the mod_proxy method is inefficient so I solved it in PHP using some simple code to determine the subdomain and apply a conditional to check that $subdomain is not an empty string.
$url_parts = explode('.', str_replace('.example.com', '', $_SERVER['HTTP_HOST']));
$subdomain = ($url_parts[0] !== '') ? $url_parts[0] : '';
I'm just redirecting to the correct page once I know that there is a subdomain.
相关推荐
最新文章