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]

```
Redirect in htaccess does not matter if it is a pdf file or anything else just a **valid link**.  

This is an example of a 301 redirect code to the link you want

`RedirectMatch 301 /subpage/ <https://www.mywebsite.com/upload/files/file.pdf>`