Solved

htaccess, rewritecond help

Posted on 2006-11-23
3
404 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

696 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