Easiest way to do 301 Redirect

I need to make index.html just go to the URL via 301 redirect. What is the easiest way to do this?

Ryan
LVL 1
catonthecouchproductionsAsked:
Who is Participating?
 
barkermn01Connect With a Mentor Commented:
Dont use rewrite unless you need to,

a redirect can be done with the code below
Redirect /index.html http://your.url.here/file.ext

Open in new window

0
 
Rajesh DalmiaCommented:
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Kailash AgheraCommented:
Do you want to redirect your root to index.html?
0
 
catonthecouchproductionsAuthor Commented:
Hey,

I am trying to get:

domain.com/index.html to always redirect to just domain.com (without the index.html)

I found examples online but they seemed to much what I was looking for.

Any ideas on how to achieve the above?

Thanks,

Ryan
0
 
Kailash AgheraCommented:
If your web site is hosted on Apache web server, try following rewrite rule:

RewriteCond %{THE_REQUEST} ^.*/index.html
 RewriteRule ^(.*)index.html$ http://www.yoursite.com/$1 [R=301,L]

- Kailash
0
 
catonthecouchproductionsAuthor Commented:
Kailash - I put your code into my htaccess file and nothing happened. Is that what I was supposed to do?

Code Snippet is below
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.fitwoman.com/$1 [R=301,L]

Open in new window

0
 
barkermn01Commented:
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.fitwoman.com/$1 [R=301,L]

What that is supposed to do is any request to a page that is not index.html get sent to index.html

But you need to have RewriteEngine On above that and some times RewriteBase /

RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.fitwoman.com/$1 [R=301,L]

Open in new window

0
 
barkermn01Commented:
O may be not sorry i just read that properly that is just wrong,

RewriteCond %{THE_REQUEST} ^.*/index.html -- this says if file is not index.html

RewriteRule ^(.*)index.html$ http://www.fitwoman.com/$1 [R=301,L] -- this says redirect anything that ends in index.html to http://www.fitwoman.com/anythingindex.html

So that should not work as they conflict with each other

And even if you removed the ReqriteCond that would be pants as it would just send you to what ever you typed in
0
 
catonthecouchproductionsAuthor Commented:
Barker - OK so how do we get one that will take index.html and make it 301 and redirect to just fitwoman.com?
0
 
catonthecouchproductionsAuthor Commented:
Barker, what you posted here, wouldnt do it:

Redirect /index.html http://your.url.here/file.ext

Trying to get: fitwoman.com/index.html -> to become just fitwoman.com

Thanks,

Ryan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.