Hello guys, basically my problem is this. I have set up a system that accepts wildcard subdomains, and rewrites them to a single CodeIgniter installation. There is a controller called dispatcher that takes the arguments that it requires, as well as being passed the subdomain being used in the URL.
My problem is this: I need to create RewriteRules that conform with CodeIgniter's URL structure. Currently I have this:
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.
It works fine for URLs that follow this format "http://example.ev-apps.com/app/method/1", but not for "http://example.ev-apps.com/app/method". It seems the precedence is all wrong, but ideally I want a solution that will work for any number of segments, for example: "http://example.ev-apps.com/app/method/1/2/3/4/5/6/7/8/9, etc.
Any help would be greatly appreciated.