skip to Main Content

I need your help

I moved my website from domain

http://www.example.com to http://oldwebsite.example.com

I have lots of pdf document with link

http://www.example.com/documents/news/test.pdf

Whenever a user click on the above link, I would like to automatically redirect all the PDF file.

http://www.example.com/documents/news/test.pdf
to
http://oldwebsite.example.com/documents/news/test.pdf


http://www.example.com/documents/news/onetest.pdf
to
http://oldwebsite.example.com/documents/news/onetest.pdf

I am using an apache server with PHP.

Thanks for your help

Tairon

2

Answers


  1. You can do this redirect old website to new website by .htaccess file. You need to update you .htaccess file in your old website folder

    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
      RewriteCond %{HTTP_HOST} ^www.olddomain.com$
      RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
    </IfModule>
    
    Login or Signup to reply.
  2. Quite easy, just use mod_rewrite. There are thousands of tutorials on the web.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search