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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:55:48+00:00 2026-05-29T06:55:48+00:00

I have got following folder structure for my domain (domain.com): /data/images (it´s subdomain name,

  • 0

I have got following folder structure for my domain (domain.com):

/data/images (it´s subdomain name, so it´s accessable via http:// images.domain.com)
/data/www (it´s subdomain name, so it´s accessable via http:// http://www.domain.com)
/data/.htaccess

And I´m trying to do:
If some image in images.domain.com doesn´t exist, rewrite URL with has request to http://www.domain.com/somescript.php, so for example
http://images.domain.com/non-existing-image.jpg
should be rewritten to
http://www.domain.com/somescript.php?id=non-existing-image.jpg.

Here is my htaccess:

RewriteEngine On  
RewriteBase /  
RewriteCond %{REQUEST_URI} \.(jpg|gif|png|bmp)$ [NC]  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule ^(.*)$ /data/www/somescript.php?id=$1 [L,QSA]

But it´s not working. Browser said: “not found”. If I tried to change path to “somescript.php” the results were “bad-request” or “not-found”.
Via access log I saw that in most cases the path to “somescript.php” is starting from “/data/www/images/” (so final path is non-existing “/data/www/images/www/somescript.php”) so I guess I need to get one level higher in my folder structure, but I don´t know how (I guess I´ve already tried almost all combinations).

Could someone please help me how to properly set the combination of RewriteBase and absolute/relative path for the “somescript.php” file?

I also want to note, that if I change the path to “http://www.domain.com/somescript.php” on the last line in my htaccess file, it works well – but due to “http://” it´s redirected and I would like to made as rewrite.

Thank you very much.

  • 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-29T06:55:49+00:00Added an answer on May 29, 2026 at 6:55 am

    Try replacing the / at the beginning of your rewrite rule. In order for it to actually go to another domain, you must specify http:// before the domain, so your last line would need to be like this:

    RewriteRule ^(.*)$ http://www.domain.com/somescript.php?id=$1 [L,QSA]
    

    If you don’t specify the http:// it’s seen as a relative path and will go off of the domain currently in use, just appending it as a regular relative path.


    Or: (This only works on some setups)

    Apache (or whatever you’re using) doesn’t go off of your user’s home directory. It uses the root directory for the website. So by specifying the / at the beginning of the domain, you’re actually saying /www/images.domain.com/<rest of absolute path>. However, if both these directories are owned by the same user, you can use a relative path to go up to the parent directory and then into the alternative directory, like so:

    RewriteRule ^(.*)$ ../www.domain.com/somescript.php?id=$1 [L,QSA]
    

    I wouldn’t recommend this much though, as relative paths can easily become broken.

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

Sidebar

Related Questions

I have got the following class structure, and have plenty of classes like C
I have come across the following link: http://code.google.com/p/a-star/source/browse/trunk/java/PathFinder.java?r=8 I have got the code working
I was following this tutorial http://nepomucenobr.com.br/blog/post/Generating-e2809cdummy-datae2809d-with-Visual-Studio.aspx and I got to the point where I
I have got the following very simple code: function init() { var articleTabs =
I have got the following issue, my function appends code to a string $string
I have got a the following problem: I have got multi-step form where in
I'm following the Django-CMS introductory tutorial and have got everything working up to the
I've got the following problem: I have two tables: (simplified) +--------+ +-----------+ | User
Ive got the following problem. I have a model called user which has a
I've got the following tables: magazine_tags news_tags page_tags content_tags faq_tags They all have exactly

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.