1 year ago

Bypass https 301 redirect for specific urls

Posted 1 year ago by james_fairhurst

I have a recent site setup with Forge using LetsEncrypt for SSL. I'm aware there's a before/ssl_redirect.conf file that 301 redirects urls to https.

What I'm trying todo is allow specific urls through so they're not redirected but just handled by Laravel so that I can show them an app 404 instead of a server 404. Any ideas? Location blocks below:

# tried this
#location /tags/view {
# also this
#location = /tags/view/general {
# this seems to work and catch all tag urls e.g. /tags/view/general, /tags/view/laravel etc
location ^~ /tags/view {
    # this has no effect and /tags/view/general 301 redirects to https 
    try_files $uri $uri/ /index.php?$query_string;
    # this works if uncommented
    #return 404;

location / {
    return 301 https://$host$request_uri;

Please sign in or create an account to participate in this conversation.