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 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

My current .htaccess looks like this: RewriteEngine On # RewriteCond %{REQUEST_URI} !^/_project RewriteCond %{REQUEST_FILENAME}
I'm trying to hide actual sub-directory from url path using mod_rewrite. The folder actual
here's the problem: when requesting url like - http://server/path/to/file.html?param=../../something/something i get response: 500 Internal
Locally this works but on the server when i do something like /user/profile i
I noticed, that sometimes (especially where mod_rewrite is not available) this path scheme is
url.rewrite-once = ( .*\.(js|ico|gif|jpg|png|css|html)$ => $0, ^/([^?]*)(\?.*)?$ => /$1.php/$2, ) This is what I
How do I rewrite a URL in ASP.NET? I would like users to be
I would like create URL rewrite rule that will set default document for my
I have successfully created rewrite rules to handle URLs like http://example.com/xyz http://example.com/xyz/ http://example.com/xyz/abc http://example.com/xyz/abc/
I have numerous index.php scripts using SEO-friendly arg format like example.com/path/to/index.php/opt/arg and would like

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.