Solved

.htaccess ro run multiple sites

Posted on 2007-04-02
1
200 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

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). #…
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.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

632 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