Reputation: 7917
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.
Upvotes: 0
Views: 128
Reputation: 1959
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 :-)
Upvotes: 1
Reputation: 3130
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.
Upvotes: 2