Jump to content

Subdomains and GET variables


therealwesfoster

Recommended Posts

I'm having trouble getting this to work for me. I always get a page load error when trying out different .htaccess methods I've found online. None work :/

 

Here's what I'm trying to do (the underlined words mean they correlate) :

Turn http://wes.sitename.com/cars/online/list?id=15

Into ./list.php?name=wes&id=15

 

So see, I'm wanting to take the subdomain and use it as the first GET var, and anything after /list to be added onto the list.php?name=wes.....

 

A good example of what I'm looking for is used on backpage .com. You'll see the subdomain as well as the additional GET vars.

 

I hope I make sense :)

Link to comment
Share on other sites

I would probably set up a wildcard virtualhost in Apache (google it), and then I would make the index file handle requests based on the URI.  For example, you could parse the blah out of blah.sitename.com/something and use it in combination with something to handle the request.

 

 

Oh, this will probably make you laugh a little:

 

http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&Sect2=HITOFF&d=PALL&p=1&u=/netahtml/PTO/srchnum.htm&r=1&f=G&l=50&s1=6,687,746.PN.&OS=PN/6,687,746&RS=PN/6,687,746

 

Don't be scared by it though, since I'm fairly sure everyone in the world has ignored it.  (Yeah, I just suggested infringing a patent.)

 

Edit:  Actually, I think it was revoked in 04 now that I reread that page.

Link to comment
Share on other sites

Ok, I've setup the wildcard subdomains. Working good.

 

Now here's my problem, the page goes on a never-ending loop when I try to load "CITY.SITE.COM".

 

Here's my sample .htaccess

Options +FollowSymlinks
RewriteEngine On

# HAS SUBDOMAIN?
RewriteCond %{HTTP_HOST} ^((??!www))[\w-]+)\.SITE\.net [NC]


RewriteRule ^((??!online))[\w-]+)/([\w-]+)/mod/([\w-]+)		./$3.php?subdomain=%1&cat=$1&slug=$2 [NC,L,QSA]

RewriteRule ^((??!online))[\w-]+)/mod/([\w-]+)			./$2.php?subdomain=%1&cat=$1 [NC,L,QSA]

RewriteRule ^online/mod/([\w-]+)							./$1.php?metro=%1 [NC,L,QSA]

 

Any help? Any more info i need to post?

 

Wes

Link to comment
Share on other sites

?! is a negative lookahead ;)

 

And there is no error message, firefox stops the process because it's a "never-ending loop".

 

The first part of this top has been solved thanks to the [QSA] flag. I'm still having troubles with the subdomain part though.

 

I'll continue to play with it while I wait for replies. I'll let you know if I figure it out. So until then, help away :)

 

Wes

Link to comment
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.