Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9019285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:44:26+00:00 2026-06-16T04:44:26+00:00

I’ve been trying to get my head around nginx rewrites today and have read

  • 0

I’ve been trying to get my head around nginx rewrites today and have read several questions/answers here as well as thoroughly read several guides I have come across.

While most things come to me quite naturally, i’m just not grasping it, perhaps due to my inexperience with any form of regular expressions.

I have a download.php script which overrides my nginx headers and forces the browser to perform a download with a ‘save as’ dialog, rather than open a fresh page.

It works perfectly however I would like to hide the url of the script itself from users.

To be specific, I would like to change this URL:

http://www.example.com/scripts/download.php?id=http://www.example.com/images/0/1/fullsize/96698298450ca01a60875e_34.jpg

So that to users it simply appears as the id GET parameter:

http://www.example.com/images/0/1/fullsize/96698298450ca01a60875e_34.jpg

But for the life of me I can’t seem to make it work.

Hopefully someone can come to rescue. Thanks in advance.

EDIT:

Just to add some further clarity to my question… The ideal solution would be for me to be able to have a link like this in my webapp:

 http://www.example.com/images/0/1/fullsize/96698298450ca01a60875e_34.jpg?dl=1

Have nginx pick up that it has a dl=1 AND is in the /images/ directory and then rewrite it to use the download script:

  http://www.example.com/scripts/download.php?id=http://www.example.com/images/0/1/fullsize/96698298450ca01a60875e_34.jpg

This way when images are only being viewed they are going through the script, and the imges are only rewritten and routed through the script when the dl=1 param is in place.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:44:27+00:00Added an answer on June 16, 2026 at 4:44 am

    If I understand your question correctly, you want to place links like http://www.example.com/images/0/1/fullsize/96698298450ca01a60875e_34.jpg&dl=1 in your web app, and when the user clicks the link they get redirected to the download.php script?

    The rewrite directive below should accomplish that, assuming you are redirecting to the same host. This will be applied to any url path starting with /images/ and query parameter dl=1. This will do a 302 (temporary) redirect. If you want a permanent (301) redirect, replace redirect with permanent.

    location /images/ {
        if ($args ~ "dl=1") {
            rewrite ^/images/(.*)$ /scripts/donwloads.php?id=$scheme://$host/images/$1 redirect;
        }
    }
    

    If you’re trying to go the other way (have links to the download.php script but redirect users to the actual resource url – not sure why, and probably a bad idea to do such a blind redirect) you could do it with this directive (it would be worth checking the id query string parameter is there)

    location /scripts/download.php {
        rewrite ^(.*)$ $arg_id? permanent;
    }
    

    Let me know if either of these solutions is in the direction you want to go, and we can adjust it to fit your needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a jquery bug and I've been looking for hours now, I can't
I have been unable to fix a problem with Java Unicode and encoding. The
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.