Forum Moderators: phranque

Message Too Old, No Replies

Rewrite with QSA

Baffled...

         

Echil0n

7:48 pm on Nov 12, 2007 (gmt 0)

10+ Year Member



I'm trying to rewrite a URL to include both the subdomain and query string. Here's what should happen:
The user goes to http://blah.example.com/, apache rewrites to http://example.com/index.php?user=blah

OR

The user goes to http://blah.example.com/cat1/subcat2/, they're served http://example.com/index.php?user=blah&cat=cat1&subcat=subcat2

This is what I have so far (this just rewrites the subdomain to a query string:


RewriteEngine On

RewriteBase /
RewriteCond %{REQUEST_URI} ^/(stats¦failed_auth\.html)/?(.*)$ [NC]
RewriteRule ^(.*)$ - [L]

RewriteCond %{HTTP_HOST} !^(www¦images¦example)\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC]
RewriteRule ^(.*)$ /home/hjennerway/example/current/index.php?cal=%1

I've tried to do this with QueryStringAppend (QSA), but I'm not having much luck:


RewriteEngine On

RewriteBase /
RewriteCond %{REQUEST_URI} ^/(stats¦failed_auth\.html)/?(.*)$ [NC]
RewriteRule ^(.*)$ - [L]

RewriteCond %{HTTP_HOST} !^(www¦images¦example)\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC]
RewriteRule ^(.*)$ /home/hjennerway/example/current/index.php?cal=%1 [QSA]

RewriteRule ^day/(\d{4})+/(\d{2})/(\d{2})/$ index.php?view=day&day=$3&month=$2&year=$1
RewriteRule ^week/(\d{4})+/(\d{2})/(\d{2})/$ index.php?view=week&day=$3&month=$2&year=$1
RewriteRule ^month/(\d{4})+/(\d{2})/(\d{2})/$ index.php?view=month&month=$2&year=$1
RewriteRule ^extmonth/(\d{4})+/(\d{2})/(\d{2})/$ index.php?view=extmonth&month=$2&year=$1
RewriteRule ^year/(\d{4})+/(\d{2})/(\d{2})/$ index.php?view=year&year=$1
RewriteRule ^category/(.*)/(.*)/$ index.php?category=$1&view=$2
RewriteRule ^category/(.*)/$ index.php?category=$1
RewriteRule ^manage/$ index.php?events=1&act=manage
RewriteRule ^manage/(.*)/(.*)/$ index.php?events=1&act=manage&view=$1&start=$2
RewriteRule ^manage/(.*)/$ index.php?events=1&act=manage&view=$1
RewriteRule ^m/$ m.php
RewriteRule ^m/day/(\d{4})+/(\d{2})/(\d{2})/$ m.php?view=day&d=$3&m=$2&y=$1
RewriteRule ^m/month/(\d{4})+/(\d{2})/$ m.php?view=month&m=$2&y=$1
RewriteRule ^m/month/(\d{4})+/(\d{2})/(.*)/$ m.php?view=month&m=$2&y=$1
RewriteRule ^m/(.*)/$ m.php?act=$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?act=$1 [L]

Thanks for any help :)

[edited by: jdMorgan at 12:16 am (utc) on Nov. 13, 2007]
[edit reason] Example.com. Please see Terms of Service. [/edit]