I will inform you briefly what I am doing and where I will need your help.
I am building blog hosting site. I finished CMS and now i am doing user pages.
My idea was to create .htaccess rules so every user and blog owner will have its own blog URL, like: XXX.bloghost.com, where XXX is blog name or blog owner name.
Just to mention that I will use 2 more parameters in URL so here are examples of URLs:
XXX.bloghost.com -> www.bloghost.com/index.php?user=XXX
XXX.bloghost.com/NEWS -> www.bloghost.com/index.php?user=XXX&category=NEWS
XXX.bloghost.com/NEWS/SAMPLE -> www.bloghost.com/index.php?user=XXX&category=NEWS&post=SAMPLE
Here is my current .htaccess file (UPDATED):
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !www.bloghost.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).bloghost.com [NC]
RewriteRule (.*) %2/$1 [L]
RewriteRule (.+)/(.+)/(.+) blog.php?blog_id=$1&category=$2&post=$3 [L,QSA]
RewriteRule (.+)/(.+) blog.php?blog_id=$1&category=$2 [L,QSA]
RewriteRule (.+) blog.php?blog_id=$1 [L,QSA]
ErrorDocument 404 /error.php
I would really need some help with this. I tried and followed several tutorials on this but with no luck.
Also, can this .htaccess block or redirect all mistyped or not existing URLs to some page?
At first, you must configure you subdomains for the wildcard
And be sure that DNS configured for wildcards too. Than use something like this:
So after this page
http://some.domain.com/newswill go tohttp://www.domain.com/some/newsAnd than process the url as usual (just for example):
But I think that second part should be handled with php routing system.