Solved

Rewrite to parent directory if not found

Posted on 2009-03-30
3
199 Views
Last Modified: 2012-05-06
I want to rewrite all files that are not found in ./webAssets/ to the parrent directory.

If this is NOT found:
./webAssets/image/graphic.gif

Then I want to rewrite the URL as:
../webAssets/image/graphic.gif

If this is NOT found:
./webAssets/media/movie.mov

Then I want to rewrite the URL as:
../webAssets/media/movie.mov
0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Expert Comment

by:caterham_www
ID: 24023534
Where do you plan to put the rewrite rules and how does the URL-path look like?

I.e. to reach
"If this is NOT found:
./webAssets/image/graphic.gif"

you're calling example.com/foo/bar/webAssets/image/graphic.gif

which should be rewritten to
example.com/foo/webAssets/image/graphic.gif

and the rewrite rules are e.g. in a example.com/foo/.htaccess?
0
 
LVL 16

Author Comment

by:hankknight
ID: 24026803
I will place the directives in an .htaccess file located here:
http://example.com/foo/bar/.htaccess

And I want
http://example.com/foo/bar/webAssets/images/pic.jpg

Rewritten here:
http://example.com/foo/webAssets/image/pic.jpg
0
 
LVL 27

Accepted Solution

by:
caterham_www earned 500 total points
ID: 24033417
You may try if relative paths in a substitution are working on your server because they're unsupported (that doesn't imply 'does not work').
RewriteEngine on
# does not exist as a file...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(webAssets/.*) ../$1 [L]

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Post form data to PHP then to 3rd party site 19 45
Guacamole and browser performance 1 125
maybe no no httpd.conf 6 77
AWS EC2 HTTP & HTTPS 2 72
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question