Hi all,
I use htaccess with a set of rules to control the different pages of my website.
- If a user visits my main site (domain.com), without using www it 301 redirects to www.domain.com (for SEO purposes)
- I use wildcard subdomains, so if a user visits subdomain.domain.com, they will view a specific PHP file that decides to content for them.
My problem is that I would like to extend my setup, to be able to use the same url names. As an example if I visit subdomain.domain.com/feed, I will see pages/public_news_feed.php file from the main domain rule, since it shared the "/feed" rule. What I really wanted to be served is pages/public_subdomain_blog_feed.php!
How can I setup specific rules for domain.com and subdomain.domain.com?
Thanks in advance and have a wonderful day!
#AuthName "Restricted Area"
#AuthType Basic
#AuthUserFile /var/www/user/data/www/domain.com/.htpasswd
#require valid-user
Options +FollowSymLinks
RewriteEngine on
#force domain setup to use www
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
#redirect subdomains to controller
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteRule ^$ pages/public_subdomain_blog.php [L,QSA]
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^(indsend-nyhed)$ pages/public_submit_news.php [L]
RewriteRule ^(modeblogs)$ pages/public_blogs.php [L]
RewriteRule ^(nyheder)$ pages/public_news.php [L]
RewriteRule ^(feed)$ pages/public_news_feed.php [L]
RewriteRule ^(nyheder)/([0-9]*)/(.*)$ pages/public_news_single.php?n_id=$2 [L]
RewriteRule ^(kontrolpanel)$ pages/private_account.php [L,QSA]
RewriteRule ^(kontrolpanel)/(logud)$ pages/private_logout.php [L]
## THESE RULES SHOULD ONLY BE SET IF THE USERS IS ON A SUBDOMAIN
RewriteRule ^([0-9]*)/(.*)$ pages/public_subdomain_blog_article.php?p_id=$1 [L]
RewriteRule ^(kategori)/([0-9]*)$ pages/public_subdomain_blog.php?c_id=$2 [L]
RewriteRule ^(arkiv)/([0-9]*)$ pages/public_subdomain_blog.php?a_id=$2 [L]
RewriteRule ^(feed)$ pages/public_subdomain_blog_feed.php [L]