htaccess Apache to Litespeed

不羁的心 提交于 2019-12-24 13:42:36

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/12220181/htaccess-apache-to-litespeed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!