Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

.htaccess - Need to send non-full-url to full url. (intranet -> intranet.hostname.com)

Posted on 2008-09-30
3
Medium Priority
?
281 Views
Last Modified: 2012-05-05
Hi all.
Using Apache and Joomla for our corp. intranet.

The intranet is accessed by a variety af url's
http://intranet http://intranet2 http://trgnet http://intranet.ourhostname.com

I want to use .htaccess to redirect all access to the full url - http://intranet.company.com

A working example would be great :-)

Thx,
Mark
0
Comment
Question by:trg_dk
[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 20

Expert Comment

by:edster9999
ID: 22605615
You could do something like :
Redirect / http://intranet.company.com

You have to be careful if the new webserver is on the same box in case you get caught in a loop.

This also means the web server must be up to resolve these names and server the redirection.

A better way would be to NOT do this in .htaccess but do it all in the DNS server then when they request a page they will end up on the right server without hitting the other web server.
Something like :

intranet        IN      CNAME   intranet.company.com.
intranet2      IN      CNAME   intranet.company.com.
trgnet          IN      CNAME   intranet.company.com.
intranet.ourhostname.com       IN      CNAME   intranet.company.com.



0
 
LVL 27

Accepted Solution

by:
caterham_www earned 2000 total points
ID: 22605648
You can check the http host with mod_rewrite only (an other approach would be to use a separate virtual host for all non-full urls and place  Redirect statement there.)

Make sure apache's module  mod_rewrite is loaded and your webserver is configured that you're allowed to use such directives in a .htaccess file.
RewriteEngine on
RewriteCond %{HTTP_HOST} !=intranet.company.com
RewriteCond %{HTTP_HOST} !=""
RewriteRule ^ http://intranet.company.com%{REQUEST_URI} [R=301,L]

Open in new window

0
 
LVL 2

Author Closing Comment

by:trg_dk
ID: 31501479
Thanks for your reply - works like a charm
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

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 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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

704 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