PDA

View Full Version : mod_rewrite



Florx
06-10-2007, 07:30 PM
Hello there!

I wonder if you could help me with mod_rewrite.

I want to have any subdomain count how many people have gone to it.

However I don't have any of the subdomains created. People can just go to random names of them and then it counts. For example:

NAME.gotowned.com or something like that where the NAME bit is changable.

Is this possible? I think it is as I have seen it on other sites before.

Thanks,
Jake

Eccentric
06-10-2007, 08:21 PM
you could have yoursite.com/name this is done the following,
if you currently have it so your usign $_get[name] eg from url like
yoursite.com/index.php?name=bob then you would use the following,

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/$ index.php?name=$1 [L]which then would result as,
yoursite.com/bob

Not what you wanted but its the closest i could do.

ScottDiamond.
06-10-2007, 08:43 PM
you could have yoursite.com/name this is done the following,
if you currently have it so your usign $_get[name] eg from url like
yoursite.com/index.php?name=bob then you would use the following,

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/$ index.php?name=$1 [L]which then would result as,
yoursite.com/bob

Not what you wanted but its the closest i could do.

He knows how to do that, thanks.

Eccentric
06-10-2007, 08:57 PM
oh.. sorry.

RichardKnox
06-10-2007, 09:29 PM
I don't think you could do it with htaccess, simply because of the fact you do not specify the URL otherwise it wouldn't work. So if (.*) is before the url it'll look for a folder called (.*)

(.*) = wildcard btw

Florx
06-10-2007, 11:06 PM
Yeh I do know how to do that :) Thanks anyway :)

Im looking for custom subdomains.

e.g. Cheese.gotowned.com

Where the variable cheese is sent to gotowned.php

Can you do that with anything?

=gamemaster=
07-10-2007, 01:00 PM
Ive seen that before, ive forgotten the link, n it plays a song with loads of owned pics


YOU GOT OWNED, OWNED OWNED ETC....

RichardKnox
07-10-2007, 01:41 PM
WELL DONE. He's using it as an example.

ScottDiamond.
07-10-2007, 02:18 PM
Ive seen that before, ive forgotten the link, n it plays a song with loads of owned pics


YOU GOT OWNED, OWNED OWNED ETC....

This is another example (http://scriptfresh.com/demo/ShortURL/u/4941).

Breakfloor
07-10-2007, 02:29 PM
Habbox.justgotowned.com

Invent
07-10-2007, 02:33 PM
Habbox.justgotowned.comClever you...

You might need a server to do this as I'm thinking you MIGHT have to put the htaccess in a higher folder, such as like /home/ not /home/account/.

Also, you might have to tweak httpd.conf? Idk lol

QuickScriptz
07-10-2007, 02:34 PM
Well... I'm not very good with .htaccess but here's what I would suggest....

Use .htaccess to redirect users to an error page that just gets the referrer and then does the counting that way. So basically you just have to setup an .htaccess file with your error pages defined as so:


ErrorDocument 404 /errors/counter.php

And then on the counter.php just have it do something with the referrer and that should help you out. So you can use PHP on the error page to see whether or not the referrer was a subdomain and if not then just dont count it :)

Invent
07-10-2007, 02:36 PM
Uhm, I don't think that helps him set up like a wildcard subdomain, so anyone can do:

sdfsdfsfsdf.hissite.com

If that doesn't exit, he'll get a DNS error as it's not a real URL as it's not defined in his virtual hosts file, etc.

Want to hide these adverts? Register an account for free!