Jump to content

Recommended Posts

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.mydomain.com/, apache rewrites to http://mydomain.com/index.php?cal=blah

 

OR

 

The user goes to http://blah.mydomain.com/day/12/, they're served http://mydomain.com/index.php?cal=blah&view=day&day=12

 

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|livezeit)\.livezeit\.net$ [NC]
RewriteCond %{HTTP_HOST} !^livezeit\.net$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.livezeit\.net$ [NC]
RewriteRule ^(.*)$ /home/hjennerway/livezeit/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|livezeit)\.livezeit\.net$ [NC]
RewriteCond %{HTTP_HOST} !^livezeit\.net$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.livezeit\.net$ [NC]
RewriteRule ^(.*)$ /home/hjennerway/livezeit/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 :)

Link to comment
https://forums.phpfreaks.com/topic/77283-rewriting-with-qsa/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.