Solved

Easiest way to do 301 Redirect

Posted on 2010-08-25
11
362 Views
Last Modified: 2012-06-27
I need to make index.html just go to the URL via 301 redirect. What is the easiest way to do this?

Ryan
0
Comment
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33528111
0
 
LVL 11

Expert Comment

by:Rajesh Dalmia
ID: 33528166
0
 
LVL 6

Expert Comment

by:Kailash Aghera
ID: 33528369
Do you want to redirect your root to index.html?
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 33528598
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
 
LVL 6

Expert Comment

by:Kailash Aghera
ID: 33528679
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Accepted Solution

by:
barkermn01 earned 500 total points
ID: 33529329
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
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 33530886
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
 
LVL 2

Expert Comment

by:barkermn01
ID: 33530951
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
 
LVL 2

Expert Comment

by:barkermn01
ID: 33530994
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
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 33531048
Barker - OK so how do we get one that will take index.html and make it 301 and redirect to just fitwoman.com?
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 33542093
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Wondering how you can get your new website ranking on Google Search so that people find you online?  The answer is Search Engine Optimization (SEO). So how do you Start Ranking a New site with SEO?  Below is a starter guide to get your new website S…
Read about how to approach blogging and about ways to do it right. Stand out from the crowd and let your knowledge be consumed by a large audience. This article aims to explain how your blog should look like,  the most important things to do while b…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now