Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

How to redirect all pages in a domain to one single page?

I have a website hosted with third party.  I have cpanel.  I want all pages to redirect to one single page. This page can either be on the same domain or a different domain.  How can I do this?
0
rbudj
Asked:
rbudj
  • 3
  • 2
1 Solution
 
ycTINCommented:
yes, you just need configure the 404 error page
and contains some code like below in your error page

<?php
header("location: http://google.com");
?>

Open in new window

0
 
ycTINCommented:
DNS redirect can do this same
0
 
rbudjAuthor Commented:
this website has more than a hundred pages.  I do not wish place code in each page.  
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Bruce PieterseTechnical LeadCommented:
Hi rbudj,

Under cPanel > Domains you can "manage redirects". This can be used for a domain or a specific address.

Ciao
0
 
rbudjAuthor Commented:
i've been trying the redirect in cpanel.  It will only redirect the one page.  It will not redirect all files in the directory.  For example... I type in mydomain.com/  to forward to anotherdomain.com/forsale.php.  If you visit a page such as mydomain.com/hello.html... it does not redirect.  Only mydomain.com/index.html will redirect.
0
 
rbudjAuthor Commented:
This is the only thing I have found that works.  In my .htaccess file... I added the following...

RewriteEngine on
RewriteRule (.*) http://www.mydomain/thepage.html [R=302,L]
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now