0

I have a blog application. and i want to set all user's accounts under subdomains. Like:

if someone type :

userx.blog.com

it must redirects to userx's blog page. i need to get that url and parse it from [].blog.com

and render requested user's page.

current profile url:

url(r'^blog/(?P<username>[-\w]+)/$', view='user_index',
name='user_index'),

in browser:

blog.com/blog/username

i hope i explained it clearly.

Thank you.

alioguzhan
  • 7,657
  • 10
  • 46
  • 67

2 Answers2

2

I did something similar with one of my sites. My solution was to use mod_rewrite in apache to redirect userx.blog.com to blog.com/blog/userx.

http://httpd.apache.org/docs/2.2/rewrite/

Apache rewrite based on subdomain

Hope that helps.

Community
  • 1
  • 1
themanatuf
  • 2,880
  • 2
  • 25
  • 39
1

You can also make something what is called "internal redirect". This will allow you to hide from user that userx.blog.com is served actually by blog.com/blog/userx.

I also recommend to use nginx server as it is superior in every way over Apache :-)

thedk
  • 1,939
  • 1
  • 20
  • 22
  • i just passed to nginx. i want to keep url as userx.blog.com after page rendered. no redirection. is it internal redirect or rewrite rule? which one is correct way for my situation? – alioguzhan Dec 14 '12 at 12:30