mysite.com/dl2/key-str TO user.mysite.com/dl2/key-str

Discuss practical ways rearrange URLs using mod_rewrite.

mysite.com/dl2/key-str TO user.mysite.com/dl2/key-str

Postby dj_spykey » Mon Nov 03, 2008 11:57 pm

Oke so i got something like

mysite.com/dl2/Sksa4saO0-12ko
its:
download.php?dl2=1&key=Sksa4saO0&ukey=12ko

i want to rewrite it to:

username.mysite.com/dl2/Sksa4saO0-12ko

example

Jhon.mysite.com/dl2/I1230MS41s-K4a0

Sksa4saO0 = key
12ko = unique-key

username = php variable ( get it from the key)

Can anyone help me?
dj_spykey
 
Posts: 8
Joined: Mon Nov 03, 2008 11:39 pm

Postby richardk » Tue Nov 04, 2008 10:27 am

As far as i can tell (because the username is not used in the original URL), you don't need any additional mod_rewrite.

You need to create DNS for the sub domains (probably Wildcard DNS). Then, Apache needs to be configured to send all the sub domain requests to the directory that contains the .htaccess file (your current document root).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby dj_spykey » Tue Nov 04, 2008 1:27 pm

so if the normal link is:

download.php?user=Jhonny_boy&key=8321FG7AS&ukey=4ace

and i want it to

Jhonny_boy.mysite.com/8321FG7AS-4ace


It can be made with .htaacces but i dont really know subdomains...
dj_spykey
 
Posts: 8
Joined: Mon Nov 03, 2008 11:39 pm

Postby richardk » Wed Nov 05, 2008 1:34 pm

No. If there is user=Jhonny_boy, then you need a different mod_rewrite.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
# Don't match the www sub domain.
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
# Match the sub domain (%1).
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteRule ^([a-z0-9]+)-([a-z0-9]+)/?$ /download.php?user=%1&key=$1&ukey=$2 [NC,QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby dj_spykey » Thu Nov 06, 2008 2:22 pm

it doesn't work
dj_spykey
 
Posts: 8
Joined: Mon Nov 03, 2008 11:39 pm

Postby richardk » Fri Nov 07, 2008 11:45 am

What happens when you go to jhonny_boy.mysite.com?
Do you have DNS for the sub domains?
Where do the sub domains go (what directory) on the server?
What is you main domain's document root?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby dj_spykey » Sat Nov 08, 2008 12:42 am

Firefox dosen't find www.jhonny_boy.mysite.com.
Root document public_html.....
i don't have DNS ..how to do that?
dj_spykey
 
Posts: 8
Joined: Mon Nov 03, 2008 11:39 pm

Postby richardk » Sun Nov 09, 2008 11:49 am

You set up DNS from where ever you registered your domain.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby dj_spykey » Tue Nov 11, 2008 3:28 am

the user is dinamic:( i have like 10000 users...i can't make dns for each one...this must be done with .htaccess
dj_spykey
 
Posts: 8
Joined: Mon Nov 03, 2008 11:39 pm

Postby richardk » Wed Nov 12, 2008 12:35 pm

the user is dinamic:( i have like 10000 users...i can't make dns for each one

Wildcard DNS.

this must be done with .htaccess

DNS is totally seperate from Apache, .htaccess and mod_rewrite.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 3 guests

cron