Solved

Rewrite to parent directory if not found

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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

21 Experts available now in Live!

Get 1:1 Help Now