Solved

Redirects on Apache web server htaccess

Posted on 2008-06-20
2
193 Views
Last Modified: 2010-03-04
Hi

Can anyone advise the best way to:

1. Set up redirects when deploying a new website can you set up a htaccess file to redirect to a page moved or not found, or do you just redirect all to a custom error page?

2. Set up custom error docs (i currently use httaccess file to redirect to chosen error page))

Many thanks

--s--
0
Comment
Question by:socross
2 Comments
 
LVL 11

Accepted Solution

by:
asafadis earned 250 total points
ID: 21832119
I hope this helps:
# Site has permanently moved to new domain

# domain.com to domain2.com

RewriteCond   %{HTTP_HOST}   ^www.domain.com$   [NC]

RewriteRule   ^(.*)$   http://www.domain2.com/$1   [R=301,L]
 
 

# Page has moved temporarily

# domain.com/page.html to domain.com/new_page.html

RewriteRule   ^page.html$   new_page.html   [R,NC,L]
 
 

# Custom error messages

# 400	Bad Requeststrange stuff with your URL or scripts.

# 401	Authorization Required

# 403	Forbidden

# 404	Not Found

# 500	Internal Server Error

ErrorDocument 404 /NotFound.html

Open in new window

0
 
LVL 1

Author Comment

by:socross
ID: 21923189
Perfect

Thanks

-s-
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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

861 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

23 Experts available now in Live!

Get 1:1 Help Now