Question: I would like to add a 301 redirect when users visit a specific page and redirect them to a PDF file.

In my **.htaccess** file I tried something like this this but it gives me a 404 error. However if I visit the path, the PDF it's there

```
Redirect 301 /subpage https://www.mywebsite/upload/files/file.pdf

```

What am I doing wrong?

PS: I am using WordPress

Answer: 
You are getting a `404` probably because the URI `/subpage` doesn't exist or map to an existent file. The `Redirect` you are using doesn't redirect the `/subpage` to the PDF location because your WordPress `RewriteRules` override it. If you want to fix it , you will need to use `RewriteRule` directive instead of `Redirect` at the top of your htaccess :

```
RewriteEngine On
RewriteRule ^/?subpage/? https://www.mywebsite.com/upload/files/file.pdf [R=301,L]

```
To target an HTML link to a specific page in a PDF file, add #page=[page number] to the end of the link's URL.

For example, this HTML tag opens page 4 of a PDF file named myfile.pdf:

```
<A HREF="http://www.example.com/myfile.pdf#page=4">

```

---

And If you want to redirect a single page to another you just need to insert this line in the .htaccess file:

Redirect 301 /old-post <https://www.yourwebsite.com/myfiles/myfile.pdf>
Going to replace the old and new addresses respectively.

The code must be inserted after and before .