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 7087545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:41:14+00:00 2026-05-28T07:41:14+00:00

I have the following rewrite rules <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME}

  • 0

I have the following rewrite rules

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^wp-content/uploads/(.*)$ dl-file.php?file=$1 [QSA,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Where every request to the wp-content/uploads its handled by dl-file.php in order to check if user its logged in.

I need to still have that functionality but grant free access to images (png|jpg|gif|jpeg)
Im a bit lost i dont know how to modify the rewrite rule to check any file that its no an image.

  • 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-05-28T07:41:15+00:00Added an answer on May 28, 2026 at 7:41 am

    before the rule that rewrites to dl-file.php you could insert more specific rules for images:

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^(wp-content/uploads/.*\.png)$ $1 [L]
    RewriteRule ^(wp-content/uploads/.*\.jpg)$ $1 [L]
    RewriteRule ^(wp-content/uploads/.*\.gif)$ $1 [L]
    RewriteRule ^wp-content/uploads/(.*)$ dl-file.php?file=$1 [QSA,L]
    

    Each of the three rules has the same structure, I’ll explain the first one:
    match anything in uploads that ends in .png
    with the brackets you save the whole path into a variable $1.

    the right hand side of the rule gives this variable, so if you look
    at one specific url this boils down to:

    Rewrite wp-content/uploads/some.png wp-content/uploads/some.png [L]
    

    the L at the end tells the rewrite engine that this is the last rule to apply.
    so if it matches, the rewriting process ends here, your png-image is served.

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

Sidebar

Related Questions

I have the following rewrite rules: <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / # Route
Currently I have these rules in my .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule
I have the following rewrite rules in my .htaccess file: RewriteEngine on RewriteRule ^news/([0-9]+)/?$
I have the following rules in my .htaccess: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond $1
I have an htaccess file as follows: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f
I've modified my .htaccess file to have the following statement RewriteCond $1 !^index.php$ RewriteRule
I have the following in my .htaccess currently- <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^go/([^/]*)/([0-9]+)/([0-9]+)/?$
I have the following rewrite rules: RewriteRule ^products/([a-zA-Z]+)$ /project/clients/index.php?database=$1&module=products [L,QSA] The directory structure is:
I have a rewrite rule of the following form: RewriteRule ^foo/([a-zA-Z0-9]+)$ foo.php?arg=$1 [qsa,nc] It
I have the following in a .htaccess file as a test: RewriteEngine on RewriteRule

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.