Link to home
Start Free TrialLog in
Avatar of TheRudy
TheRudy

asked on

htaccess, rewritecond help

Hello

I need some help with htaccess.

What i have currently:
- if user types in main domain (mydomain.com) he sees main page
- if user types in his subdomain (subdomain.mydomain.com) he sees his own page
- if user types in his addon domain (addondomain.com) he sees his own page (same as above with subdomain but this time with domain name)

This is working just fine they way it should!
In htaccess all i used was this:

RewriteRule ^index.php$ index.php?domain=%{HTTP_HOST}

and i do the rest of the stuff in PHP, check what domain name was entered or subdomain if any...

But now on main page i have subpages and while they are really PHP files i want them to show like mydomain.com/page1.html which would redirect to index.php?domain=mydomain.com&pageid=page1

So i did it like this:

RewriteRule ^([A-Za-z0-9_]+).html$ index.php?domain=%{HTTP_HOST}&pageid=$1
RewriteRule ^index.php$ index.php?domain=%{HTTP_HOST}

Still the same!
If i remove last line then of course the .html links work but subdomains and addon domains show mydomain.com page instead of users page.

I'm guessing that RewriteCond will need to be used and i have tried a few things but cannot get it working..
ASKER CERTIFIED SOLUTION
Avatar of Robin Hickmott
Robin Hickmott

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial