Solved

.htaccess ro run multiple sites

Posted on 2007-04-02
1
199 Views
Last Modified: 2010-03-04
This file works great, but only for 1 domain. I need to add a 2nd running from the folder /v2/

Its fine to show the subfolder in the urls, but I would also like this script to check for the "www." prefix and remove it. How can I configure the htaccess to rewrite the urls properly ?

Goal ..
http :// domain1 .com /site/
http :// domain2 .com /v2/

Here is the code Im starting with:
---
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^$ /site/ [L,R]
0
Comment
Question by:mcsolas
[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
1 Comment
 
LVL 11

Accepted Solution

by:
JamesCssl earned 500 total points
ID: 18841045
#remove the WWW
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^/?(.*) http://%1/$1 [R=301,L]

# example.com
RewriteCond %{REQUEST_URI} !^/?site
RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteRule ^/?(.*)$ /site/$1 [L]
RewriteRule ^/?site/$ - [L]

# example.net
RewriteCond %{REQUEST_URI} !^/?v2
RewriteCond %{HTTP_HOST} example\.net [NC]
RewriteRule ^/?(.*)$ /v2/$1 [L]
RewriteRule ^/?v2/$ - [L]

Replace example.com and example.net with your domains, and "site" and "v2" with your paths.
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Configuring Apache Camel to send and recieive from QPID Broker 2 75
.htaccess rewrite url with querystring problem 13 125
PHP Register global 21 119
Apache LDAP Authentication 20 72
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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