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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:09:51+00:00 2026-05-14T04:09:51+00:00

So I rewrote my paths to something like: URL/really/nice/paths/ using mod_rewrite rules like this:

  • 0

So I rewrote my paths to something like: URL/really/nice/paths/ using mod_rewrite rules like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>

The question is how could I rewrite the paths for js/css/image files too, so when they are requested with a relative path from URL/really/nice/path/ to be served from URL/scripts/, URL/styles/ and URL/images/ folders instead? Can this be done without using RewriteBase?

  • 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-14T04:09:51+00:00Added an answer on May 14, 2026 at 4:09 am

    When URLs are rewritten, the client doesn’t know it. So when a client looks at a page at the URL “example.com/some/url/” and the page references an image in “images/image.jpg”, the client looks for the image in “example.com/some/url/images/image.jpg” even though the page actually resides in “example.com/some/other/url/”. That’s the problem you’re facing, right?

    There are three main solutions to this problem:

    1. Use absolute paths to resources instead of relative ones.
    2. Use the <base> tag to ensure that the client knows the root upon which to build its relative URLs is different from the page’s apparent URL.
    3. Add a new rule for “some/url/images/” in your rewrite rules.

    Option 1 is probably the best idea, and you’ll find that most sites that use URL rewriting use it, including Stack Overflow itself. Option 2 is frowned upon, but works and is relatively easy. Option 3 is the most difficult to maintain, as URL rewriting exceptions and special cases can appear as you’re defining new rules.

    The most maintainable solution is to use absolute URLs.

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

Sidebar

Related Questions

How do I rewrite a URL in ASP.NET? I would like users to be
If I use mod_rewrite to control all my 301 redirects, does this happen before
I am trying to rewrite URLs using mod_rewrite. It is enabled in httpd.conf and
I have this rewrite rule RewriteEngine On RewriteBase /location/ RewriteRule ^(.+)/?$ index.php?franchise=$1 Which is
I rewrite URLs to include the title of user generated travelblogs. I do this
I rewrite my old code in new style, like below: #old style open(FD,file); #new
How do you rewrite this in Linq? SELECT Id, Name FROM TableA WHERE TableA.Id
How to rewrite this: select tab1.id, tab2.id, tab3.id from tab1, tab2, tab3 where tab1.col1
I know you can do redirection based on the domain or path to rewrite
I am attempting to rewrite my ForestPad application utilizing WPF for the presentation layer.

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.