Jump to content

How to redirect from an existent file path in the site directory or throw a 404 when its URI is requested?


Recommended Posts

Posted (edited)

Specifically is it not possible to intercept the file path being accessed directly via PHP? I know htaccess can be used on Apache server; what about on Nginx, since it only has a single access config file per server?

How does ProcessWire implement its access directives in nginx?

Edited by hellomoto
typo
Posted

Considering you have i.e. `example.com/site/assets/file.zip` being accessed, you could: 

1. Add a rule on Nginx as you mentioned. But ProcessWire won't help you with that; you need to change the Nginx config yourself. 

location = /some/spec/path/ {
    root /home/myweb/path;
    try_files /file.zip =404;
}

//NOT TESTED!

2. Or, if you are using Cloudflare as DNS provider, you can add a rule there to create the redirect without touching your server.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...