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

Here is code: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI} !^/rt/ RewriteRule ^(.*)$ /rt/$1 [L]
i am trying to rewrite any URL that match this pattern: ~/Ahmed ~/Name to
Completely rewrote the question as I now have more information about what is happening.
How can I rewrite this section to be more professional? Maybe there is some
I need to rewrite a dynamic URL. The content myurl and mytext is always
can anybody please tell me the rewrite rule so I can make a URL
I'm using the DyninstAPI (namely, the SymtabAPI component) to rewrite the symbol tables in
How can I include an if statement in my loop conditional in XSLT? I
TLDR: I'm looking for a way to serve web resources (css, jpg, etc) from
I have a mod rewrite rule for pagination of my content: RewriteRule ^content/page/([^/]*)$ /index.php?page=$1

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.