?
Solved

Htaccess to parent directory that contains other htaccess

Posted on 2010-01-13
3
Medium Priority
?
533 Views
Last Modified: 2013-11-30
Hi !

I have a problem with a .htaccess file that do not redirect when client using ../ (parent directory) in a src link.

I have a parent directory with two folders in it: "images", "users_ftp"  and "subdir". The child directory "subdir" contais all html-pages.

The problem I have is when I want to get a file from parent/users_ftp ex. ../users_ftp/page.html  
It seems to ignore the row:RewriteCond %{REQUEST_URI} !^.*\.\.\/.* [NC]

.htaccess in parent directory:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^localdomain\.se.* [NC] [AND]
RewriteCond %{REQUEST_URI} !^.*\.\.\/.* [NC]
RewriteRule ([\w\-_\d]*\.html.*) http://www.domain.se/subdir/parse.php?p=$1 [NC,P]

.htaccess in child directory ("subdir"):
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^localdomain\.se.* [NC] [AND]
RewriteCond %{REQUEST_URI} !^.*\.\.\/.* [NC]
RewriteRule (.*\.html.*) http://www.domain.se/subdir/parse.php?p=$1 [NC,P]

0
Comment
Question by:Haveland
2 Comments
 
LVL 26

Accepted Solution

by:
arober11 earned 1000 total points
ID: 26304465
Hi

Try:

.htaccess in parent directory:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ! localdomain\.se [NC]
RewriteCond %{REQUEST_URI} ! \.\./ [NC]
RewriteRule ([\w\-_\d]*\.html) http://www.domain.se/subdir/parse.php?p=$1 [NC,P]

.htaccess in child directory ("subdir"):
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^localdomain\.se [NC]
RewriteCond %{REQUEST_URI} ! \.\./ [NC]
RewriteRule ([^/]*\.html) http://www.domain.se/subdir/parse.php?p=$1 [NC,P]

0
 

Author Comment

by:Haveland
ID: 26311705
Thank you!

the part !\.\./ worked.
But I found a solution omn my problem that was more simple then my earliar code:

.htaccess in parent directory (files do not exist in this folder):
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^.*localdomain\.se.* [NC]
RewriteCond %{REQUEST_URI} !^\.\./ [NC]
##File do not exist in parent folder so go in to subfolder but if folder/file exist it uses that file.
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ([\w\/\-_\d]*\.[\w]*.*) http://www.domain.se/subdir/$1 [NC,P]

.htaccess in child directory ("subdir"):
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^localdomain\.se.* [NC]
RewriteRule (.*\.html.*) http://www.domain.com/subdir/parse.php?p=$1 [NC,P]

Thanks!
Tommy
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

This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
Unable to change the program that handles the scan event from a network attached Canon/Brother printer/scanner. This means you'll always have to choose which program handles this action, e.g. ControlCenter4 (in the case of a Brother).
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

621 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