I am aware that this question has already asked in one way or another, but nor the question description nor the answers were working/satisfactory. So I try to explain the issue as clearly as possible.
SAMPLE FOLDER STRUCTURE
.htaccess
index.php
[subfolder-dog]
---- index.php
---- image.jpg
---- [animals]
--------- index.php
--------- cat.jpg
--------- dog.jpg
--------- frog.jpg
SAMPLE DOMAIN
- www.dog.com
INTENSION
Guest visiting the website at www.dog.com, should be presented with the subfolder content without ever showing the subfolder in the URL. To make this more clear. http://www.dog.com/image.jpg
should show the image and keep that in the URL, not that suddenly it will show http://www.dog.com/subfolder-dog/image.jpg
.
HTACCESS (SO FAR)
# Turn on Apache mod_rewrite
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
# IF THE HOST COMES FROM THE DOMAIN WWW.DOG.COM
RewriteCond %{HTTP_HOST} ^www.dog.com$ [NC]
# AND IF THE REQUESTED URL DOES NOT ALREADY CONTAIN THE SUBFOLDER-DOG
RewriteCond %{REQUEST_URI} !^/subfolder-dog/.*$ [NC]
# REWRITE BY PREPENDING EVERY REQUEST WITH SUBFOLDER-DOG
RewriteRule (.*) subfolder-dog/$1 [L]
RESULT
At first sight, this will work as expected.
- http://www.dog.com – Works and shows the index.php within [subfolder-dog]
- http://www.dog.com/image.jpg – Works and shows the image within [subfolder-dog]
- http://www.dog.com/animals/frog.jpg – Works and shows the image within [subfolder-dog/animals]
- http://www.dog.com/animals/ – Works and shows the index.php within [subfolder-dog/animals]
The big problem only occurs on directories without trailing slashes.
- http://www.dog.com/animals – WRONG the URL in the address bar becomes http://www.dog.com/subfolder-dog/animals. For some unpredictable reason now the subfolder is no longer hidden in the addressbar
This wil become extremely annoying when you try and install WordPress! When putting all the WordPress files within the subfolder-dog
folder and going to http://www.dog.com all seems normal. When clicking on “Create configuration file” button, the address bar now says http://www.dog.com/subfolder-dog/wp-admin/setup-config.php. When you correct the URL by removing the subfolder from the URL it requests a file again and it works again.
I’ve been stuck on this issue for a week now, hopefully someone can shine a light on this subject. It’s starting to make me crazy.
Try the following:
OR
Hope this help you!!!