Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I don't seem to be able to do the following in my .htaccess
I have my script in a sub-folder inside my root directory, let's call it "ecommerce", and inside that sub-folder I have my .htaccess. I Am trying to make going to a certain sub-folder inside "ecommerce" load a certain page within the 2nd sub-folder, let's called it "shirts".

Here is my code:

RewriteEngine On
RewriteRule ^ecommerce/shirts/$ /ecommerce/shirts/shirts.php

Here are the address/locations of the the files and folders:


What am trying to do is, if I open


I'll get access to my shirts.php inside, instead of the folder directory. Ofc I made sure that I have mod-writing enabled on my Apache server. Thanks in advance for you help.

share|improve this question

migrated from Mar 29 '13 at 9:45

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

When you have a .htaccess in a sub folder, Apache strips the directory prefix from the request URL. Therefore, the RewriteRule pattern must not include the directory prefix

RewriteEngine On
RewriteRule ^shirts/$ /ecommerce/shirts/shirts.php
share|improve this answer
I tried doing that, but I got the following: Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. Error 404 localhost Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 – Khaled Mar 27 '13 at 23:16
@Khaled Then you have no example.php in the example-folder2 directory. I tested this locally and it works as intended. Please see updated answer. – Olaf Dietsche Mar 27 '13 at 23:24
I will re edit my original post, to include some data that might help and clear the confusion am causing here. ^^ – Khaled Mar 27 '13 at 23:25
It has been updated. – Khaled Mar 27 '13 at 23:50
@Khaled Then the first rule works. – Olaf Dietsche Mar 28 '13 at 0:03

You must log in to answer this question.