Solved

Redirects on Apache web server htaccess

Posted on 2008-06-20
2
194 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

786 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