?
Solved

Easiest way to do 301 Redirect

Posted on 2010-08-25
11
Medium Priority
?
369 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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
 
LVL 2

Accepted Solution

by:
barkermn01 earned 2000 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

The Ideal Solution for Multi-Display Applications

Check out ATEN’s VS1912 12-Port DP Video Wall Media Player at InfoComm 2017. Kerri describes how easy it is to design creative video walls in asymmetric layouts and schedule detailed playlists ahead of time with its advanced scheduling feature.

Question has a verified solution.

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

If you don’t want your company's site to fail on the web, you’d do well to observe these best web design practices and make sure you implement them when applicable.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
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…

801 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