Solved

Redirects on Apache web server htaccess

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Modify PHP Code on the Fly? 8 40
PHP connection to remote AWS MySQL RDS 4 38
resizeing PHP image 2 22
Wordpress Body Class 5 11
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

705 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

16 Experts available now in Live!

Get 1:1 Help Now