Solved

htaccess, rewritecond help

Posted on 2006-11-23
3
397 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

19 Experts available now in Live!

Get 1:1 Help Now