Solved

Rewrite to parent directory if not found

Posted on 2009-03-30
3
194 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
  • 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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now