htaccess的阿帕奇的Litespeed [英] htaccess Apache to Litespeed

查看:187
本文介绍了htaccess的阿帕奇的Litespeed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用我的开发环境下重写(阿帕奇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.

这篇关于htaccess的阿帕奇的Litespeed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆