Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Rewrite to parent directory if not found

Posted on 2009-03-30
3
Medium Priority
?
209 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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 …
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

971 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