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
Solved

Easiest way to do 301 Redirect

Posted on 2010-08-25
11
366 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Online promotion is consistently becoming more important for all types of businesses. From Facebook ads to search engines to YouTube videos, there are all sorts of channels that can effectively be used to promote a business or product. But how shoul…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

839 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