0

I have website1.com setup so that when users visit website1.com they get redirected via a meta tag in an index.html to website1.com/directory

Then they use the website and go to links such as website1.com/directory/index.html or what ever. I am trying to hide the "directory" in the link so that users only see website1.com/index.html

I have place the htaccess which is to rewrite the url to website1.com/index.html at website1.com/directory/.htaccess

I am not doing anything else special and this should be an easy task. My current exact htaccess is as follows:

RewriteEngine On
RewriteCondition %{REQUEST_URI} !^directory/
RewriteRule ^(.*)$ directory/$1 [L]

Should be easy right..... All I get is a 404

In my server I have Mod_Rewrite & mod security and suspect one of them is causing this not to work but can't imagine why. Am I missing something here?

user3399760
  • 27
  • 1
  • 7

1 Answers1

0
  1. Your rule is incorrect since %{REQUEST_URI} variable has starting /
  2. You need to place this in document root

Use this code in document root .htaccess:

RewriteEngine On
RewriteCondition %{REQUEST_URI} !^/directory/
RewriteRule ^(.*)$ /directory/$1 [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643