Solved

htaccess, rewritecond help

Posted on 2006-11-23
3
396 Views
Last Modified: 2012-06-21
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..
0
Comment
Question by:TheRudy
3 Comments
 
LVL 13

Accepted Solution

by:
rhickmott earned 125 total points
ID: 18003582
What about

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

The L means it will stop processing rules if it has been matched (if the first one matches ignore the second)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now