?
Solved

Htaccess to parent directory that contains other htaccess

Posted on 2010-01-13
3
Medium Priority
?
529 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
[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
3 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

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

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

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Suggested Courses

743 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