【发布时间】:2011-03-30 22:04:40
【问题描述】:
基本上我的问题是这样的。我已经建立了一个接受通配符子域的系统,并将它们重写为单个 CodeIgniter 安装。有一个名为 dispatcher 的控制器,它接受它需要的参数,以及传递 URL 中使用的子域。
我的问题是:我需要创建符合 CodeIgniter 的 URL 结构的 RewriteRules。目前我有这个:
RewriteEngine On
# Extract the subdomain part of domain.com
RewriteCond %{HTTP_HOST} ^([^\.]+)\.ev-apps\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# Check that the subdomain part is not www and ftp and mail
RewriteCond %1 !^(www|ftp|mail)$ [NC]
# Redirect all requests to a php script passing as argument the subdomain
RewriteRule ^/(.*)/(.*)$ /dispatcher/run_app/$1/$2/%1 [L,QSA] # First is app name, then site, then action
RewriteRule ^/(.*)/(.*)/(.*)$ /dispatcher/run_app/$1/$2/$3/%1 [L,QSA] # First is app name, then site, then action, then any passed data.
它适用于遵循这种格式“http://example.ev-apps.com/app/method/1”的 URL,但不适用于“http://example.ev-apps.com/app/method”。似乎优先级都是错误的,但理想情况下,我想要一个适用于任意数量段的解决方案,例如:“http://example.ev-apps.com/app/method/1/2/3/4/5/6/7/8/9, etc.
任何帮助将不胜感激。
【问题讨论】:
标签: apache .htaccess codeigniter httpd.conf