Solved

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

Posted on 2008-09-30
3
274 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
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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

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