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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:46:40+00:00 2026-06-13T02:46:40+00:00

I have a .htaccess file intended to get images, js and css from the

  • 0

I have a .htaccess file intended to get images, js and css from the corresponding folders just by getting the file extension. It should always get the files from /img, /js and /css in the root folder.

The lines I have for css and js work fine:

RewriteRule ^(([a-zA-Z0-9\-\.\/]+)/)?([a-zA-Z0-9\-\.]+).js$ js/$3.js [NC,L]
RewriteRule ^(([a-zA-Z0-9\-\.\/]+)/)?([a-zA-Z0-9\-\.]+).css$ css/$3.css [NC,L]

But when I try to use a similar line for the images I get a 403 “You don’t have permission to access /img/ on this server.” error:

RewriteRule ^(([a-zA-Z0-9\-\.\/]+)/)?(([a-zA-Z0-9\-\.]+).(jpg|png|svg|gif))?$ img/$3 [NC,L]

Everything work fine in the home page, but if you try to another page like mydomain.com/contact/ you get the 403 error. Even if you copy and paste the image URL in your browser it opens fine.

I tested the regular expression here and it’s fine. What could be causing the problem?

  • 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-13T02:46:41+00:00Added an answer on June 13, 2026 at 2:46 am
    RewriteRule ([a-z0-9\-\.]+)\.(js|css)$ $2/$1.$2 [NC,L]
    RewriteRule ([a-z0-9\-\.]+)\.(jpe?g|png|svg|gif)$ img/$1.$2 [NC,L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have the following .htaccess file contents from my other project which is
I have an htaccess file that is supposed to be redirecting any non-existing files/folders/etc
So I have a .htaccess file which is performing a rewrite from /testscript1.php/testvar1/testvar2 to
I have an .htaccess file using mod_rewrite to redirect URLs from the old website
I have such .htaccess file: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php
I have a .htaccess file in the root of a website: /var/www/mywebsite/htdocs/.htacess and I
I have this .htaccess file in WordPress. It's located at /public_html/ (web root). I
I have an .htaccess file with following content: AddHandler x-httpd-php5 .php For some reason,
I currently have a .htaccess file set up with this rule: RewriteRule ^([a-zA-Z0-9_-]+)$ user\.php?user=$1
Say I have a htaccess file shared by dev.server and server.site.com. The first domain

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.