Welcome Guest, Not a member yet? Register   Sign In
htaccess redirects
#1

[eluser]ggoforth[/eluser]
hello all! I'm in the middle of trying to get a url like:

my-username.mydomain.com

to rewrite to:

mydomain.com/my-username

I have this working perfectly, but now I'm wondering if this can be done silently (instead of doing a hard redirect to the proper URL, the domain stays as my-username.mydomain.com).

I'm doing the redirect via .htaccess, and again, it's working fine, now I'm just wondering how to do it without changing the URL in the browser (if it's possible).

thanks to anyone that might have experience with this!

Greg
#2

[eluser]Bondie[/eluser]
I believe people relate to them as dynamic subdomains.

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourwebsite.com
RewriteCond %{HTTP_HOST} ([^.]+)\.yourwebsite.com
RewriteRule ^(.*)$ /path_to_your_site/public_html/profile.php?id=%1

Quote:This will render abcd.yourwebsite.com into yourwebsite.com/profile.php?id=abc
Isnt it simple enough ?

Hope this helps you, no idea if this works or not. Not personally tried by me, simpily Google'd.

Resource:
http://keyboarddance.wordpress.com/2007/...-htaccess/
#3

[eluser]ggoforth[/eluser]
Hi Bondie,

What you've got here is exactly how I'm doing it, BUT in the rewrite rule I'm using the full domain so I'm doing:

RewriteRule ^(.*)$ http://www.mydomain.com/profile.php?id=%1

I wonder if doing the path (instead of a full domain) as you've outlined it here will run the redirect silently instead of showing the new URL in the address bar....gonna give it a shot.

Greg
#4

[eluser]Bondie[/eluser]
As I've said I havn't personally tried it, but heard of people using it and naming it "dynamic subdomains" so I gave it a bit of a Google and found that article, if this doesn't help sorry for wasting your time, and all the best in finding the solution, if you find a working solution, I would love to know also Smile

Good night Smile
#5

[eluser]ggoforth[/eluser]
[quote author="Bondie" date="1248151371"]As I've said I havn't personally tried it, but heard of people using it and naming it "dynamic subdomains" so I gave it a bit of a Google and found that article, if this doesn't help sorry for wasting your time, and all the best in finding the solution, if you find a working solution, I would love to know also Smile

Good night Smile[/quote]

Waste of time, not at all! I'm thinking you actually gave me a hint as to what I need to do. Gonna try in a few minutes. I will let you know if it works.

greg
#6

[eluser]Bondie[/eluser]
I'm off for some well deserved sleep, been a busy day, if you do find a way, I would love to know, message me? Big Grin

Good night from the UK Tongue




Theme © iAndrew 2016 - Forum software by © MyBB