Aaron
Aaron

Reputation: 3669

htaccess redirect my entire site except 1 file

I am trying to redirect my whole site including all sub directory's to www.mysite.com/index.html file.

I have had a look around and found that you use .htaccess to do it and just need some help in stopping the redirect when the index.html is called.

My .htaccess file looks like this so far:

RewriteEngine On

RewriteCond %{REQUEST_URI} !=/index.html
Redirect 301 / http://www.MySiteHere.com/index.html

So what the above does is redirects everything on my site to the index.html which I want to do, but then it keeps requesting the index.html file. So I need some help stopping the .htaccess file from running when the index.html file is requested.

Anyone got any ideas?

Upvotes: 1

Views: 156

Answers (1)

Jon Lin
Jon Lin

Reputation: 143946

You've mish-mashed directives from 2 different modules here. RewriteCond is part of mod_rewrite, and it gets applied to only the next immediately following RewriteRule directive. The Redirect directive is part of mod_alias, and it gets applied in a completely different place in the URL-file mapping pipeline. It looks like you'll just want to stick with mod_rewrite:

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule ^ http://www.MySiteHere.com/index.html [L,R=301]

Upvotes: 1

Related Questions