Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-14-2005, 11:02 AM   PM User | #1
mrruben5
Regular Coder

 
Join Date: Nov 2004
Location: The Netherlands
Posts: 551
Thanks: 0
Thanked 0 Times in 0 Posts
mrruben5 is an unknown quantity at this point
Mod rewrite on a subdomain with redirects

I have a subdomain, and I want to send uri's to the new subdomain using a redirect:

http://www.mydomain.com/subdomain/^anythinghere$
must go to :

http://subdomain.mydomain.com/^anythinghere$

I also want mod rewrite:

http://subdomain.mydomain.com/^anythinghere$/

must be rewritten as:

http://subdomain.mydomain.com/index.php?q=^anythinghere$

How would I do this?
__________________
CATdude about IE6: "All your box-model are belong to us"
mrruben5 is offline   Reply With Quote
Old 07-14-2005, 05:09 PM   PM User | #2
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
In you main domain root directory a .htaccess files with
Code:
RewriteEngine ON
RewriteRule ^/subdomain/?$ http://subdomain.mydomain.com/ [R,QSA]
RewriteRule ^/subdomain/(.*)/?$ http://subdomain.mydomain.com/$1 [R,QSA]
And in the subdomain root directory a .htaccess files with
Code:
RewriteEngine ON
RewriteRule ^(.*)$ index.php?q=$1 [QSA]
(i haven't actually tested this so if there's a problem just ask)
Ps. remember to change subdomain in the first .htaccess file to your subdomain's name.
schleppel is offline   Reply With Quote
Old 07-14-2005, 11:55 PM   PM User | #3
mrruben5
Regular Coder

 
Join Date: Nov 2004
Location: The Netherlands
Posts: 551
Thanks: 0
Thanked 0 Times in 0 Posts
mrruben5 is an unknown quantity at this point
Thanks, that's exactly what I was looking for. I understand that [R] will send a redirect header to the browser, but what does [QSA] do? Oh yeah, using the index.html to index.php?q=index with the R flag would break the use of mod_rewrite, hahaha.

[edit:NVM.]
Quote:
This flag forces the rewriting engine to append a query string part in the substitution string to the existing one instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.
[/edit]
__________________
CATdude about IE6: "All your box-model are belong to us"

Last edited by mrruben5; 07-15-2005 at 12:19 AM..
mrruben5 is offline   Reply With Quote
Old 07-15-2005, 03:48 PM   PM User | #4
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
if you want http://subdomain.yourdomain.com/ to go to index.php?q=index you can use this:
Code:
RewriteEngine ON
RewriteRule ^$ index.php?q=index [QSA]
RewriteRule ^(.*)$ index.php?q=$1 [QSA]
schleppel is offline   Reply With Quote
Old 08-08-2005, 09:22 AM   PM User | #5
mrruben5
Regular Coder

 
Join Date: Nov 2004
Location: The Netherlands
Posts: 551
Thanks: 0
Thanked 0 Times in 0 Posts
mrruben5 is an unknown quantity at this point
Another mod rewrite question. Can I "cloak" an url with mod_rewrite?

eg: http://www.encyshop to http://www.iceshop.nl/encyclue/store?
__________________
CATdude about IE6: "All your box-model are belong to us"
mrruben5 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:46 AM.


Advertisement
Log in to turn off these ads.