1) On your website, make sure that you generate PROPER URLs, e.g. http://minecraft.domain.com/1/lorem-ipsum
instead of /article.php?id=1&category=Minecraft&Name=Lorem+Ipsum
Here, the acceptable characters for the article name is:
- any latin characters (can be mixed case, but I would recommend to have all lower case)
- digits
- underscore char
_
- minus char
-
Any other characters should be replaced by -
. If during URL normalisation you end up with more that 1 -
character next to each other -- remove such extra chars. The article name should not start or end with -
or _
.
Example of normalisation process (step-by-step):
Oops! I did it again!
-- initial text
oops--i-did-it-again-
-- after replacing unwanted characters by -
oops-i-did-it-again-
-- removing duplicated -
characters
oops-i-did-it-again
-- final sting after removing trailing -
2) Setup your subdomain minecraft.domain.com
to point into the same root folder as domain.com
3) Add these rules into your .htaccess
# Activate Rewrite Engine
RewriteEngine On
# Do not do anything for already existing files
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
# rewrite root (topic) hit
RewriteCond %{HTTP_HOST} ^minecraft\.domain\.com$
RewriteRule ^$ /topic.php?category=Minecraft [QSA,L]
# rewrite article hits
RewriteCond %{HTTP_HOST} ^minecraft\.domain\.com$
RewriteRule ^(\d+)/([a-z0-9\-_]+)$ /article.php?id=$1&category=Minecraft&Name=$2 [NC,QSA,L]
These rules will do these rewrites:
minecraft.domain.com
=> /topic.php?category=Minecraft
minecraft.domain.com/1/lorem-ipsum
=> /article.php?id=1&category=Minecraft&Name=lorem-ipsum
UPDATE:
These rules will work for any subdomains (including www.domain.com) -- replace last 6 lines from previous snippet:
# rewrite root (topic) hit
RewriteCond %{HTTP_HOST} ^([a-z0-9\-]+)\.domain\.com$ [NC]
RewriteRule ^$ /topic.php?category=%1 [QSA,L]
# rewrite article hits
RewriteCond %{HTTP_HOST} ^([a-z0-9\-]+)\.domain\.com$ [NC]
RewriteRule ^(\d+)/([a-z0-9\-_]+)$ /article.php?id=$1&category=%1&Name=$2 [NC,QSA,L]
It is YOUR responsibility to generate PROPER URLs. The above rules will make these NICE urls working.