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

  • Home
  • SEARCH
  • 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 6812519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:27:32+00:00 2026-05-26T20:27:32+00:00

I have a .htaccess file on a website I’m working on which rewrites urls

  • 0

I have a .htaccess file on a website I’m working on which rewrites urls from mydomain.com/sub/folder/ to mydomain.com?index.php?controller=sub&view=folder

Unfortunately the way I’ve written it means I can’t access images, stylesheets and other linked files anymore. Could anyone tell me how best to exclude specific directories / URL requests from the rewrite rule?

Apologies if this is a bit of a newbie question, I’m still wrapping my head around this mod rewrite stuff!

The .htaccess file looks like this:

RewriteEngine on
RewriteRule ^([a-zA-Z0-9-]+)/?$ index.php?Controller=$1
RewriteRule ^([a-zA-Z0-9-
]+)/([a-zA-Z0-9-_]+)/? index.php?Controller=$1&View=$2

  • 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-26T20:27:33+00:00Added an answer on May 26, 2026 at 8:27 pm

    If your images are in mydomain.com/images and you are linking to them using relative links on the page mydomain.com/sub/folder/ the browser is going to try to attempt to access the image via mydomain.com/sub/folder/images/i.gif. But if you change your links to absolute links, the browser will correctly attempt to load mydomain.com/images/i.gif. However, the RewriteRule will change it to: mydomain.com/index/php?Controller=images&View=i.gif. To avoid this you need to add a few RewriteConds:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z0-9-_]+)\/?$ index.php?Controller=$1
    RewriteRule ^([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)\/? index.php?Controller=$1&View=$2
    

    So that when attempting at access an existing file/directory, don’t rewrite to index.php.

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

Sidebar

Related Questions

I have an .htaccess file using mod_rewrite to redirect URLs from the old website
So I have the following .htaccess file contents from my other project which is
I have website which works fine and have following in the htaccess file RewriteEngine
I have a .htaccess file in the root of a website: /var/www/mywebsite/htdocs/.htacess and I
Say I have a htaccess file shared by dev.server and server.site.com. The first domain
I have a classifieds website. Each classified is linked like this originally: mydomain.com/ad.php?ad_id=Bmw_M3_M_tech_113620829 What
Currently I have a url like this http://<client_name>.website.com/index.php?function_name&cat=32 I want to set things up
I have the following in my .htaccess file, which I do often for cleaner
I'm working on an aircraft website and using a .htaccess file to rewrite the
There is a problem with my .htaccess file. If I type in website.com it

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.