Solved

Easiest way to do 301 Redirect

Posted on 2010-08-25
11
364 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

24 Experts available now in Live!

Get 1:1 Help Now