homepage Welcome to WebmasterWorld Guest from 54.145.172.149
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
Forum Library, Charter, Moderators: phranque

Website Technology Issues Forum

    
301 Redirection
SunnyG



 
Msg#: 4611178 posted 6:41 am on Sep 20, 2013 (gmt 0)

Hi members,
I need your help to solve a unique 301 problem [for me :( ] in one of my websites. And the problem is, all the below mentioned urls [example] shows 301.

say for example -
1] www .domain .com
2] domain .com
3] www .domain .com/index.html
4] domain .com/index.html

I am getting this in one of reliable 301 checking tools.

Can you pls. tell how to solve this?

Thanks
SunnyG

 

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4611178 posted 7:02 am on Sep 20, 2013 (gmt 0)

You'll need two Rewriterules one for the index and hostname redirect and one for the hostname redirect.

The code for this has been published many times before. Check through these:

[google.com...]

Use "example.com" in all forum code examples. This suppresses the forum auto-linking function.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4611178 posted 9:42 am on Sep 20, 2013 (gmt 0)

phranque, you out there? A while back someone had an issue with one of those URL-checking tools. Turns out it wasn't returning the correct results for one category of variation. (Don't remember what, and it doesn't really matter, but it was something utterly basic like with/without www or the explicit /index.html name.) So either they thought they had a problem when they didn't really, or they did have a problem and the tool wasn't helping.

1] www.example.com
2] example.com
3] www.example.com/index.html
4] example.com/index.html

3 and 4 should both redirect to either 1 or 2. So should anything else in index.html; it's typically your second-to-last redirect.

Either 1 or 2 (your choice, so long as you're consistent) should redirect to the other. This is typically your last and most general redirect.

This is assuming for the sake of discussion that "index.html" is the actual name of your physical index file. If it's called something else, such as index.php, it's again your choice whether you want to redirect at all, or let bad requests pick up a 404.

But what I really want to know is whether it's a redirect issue or a tool issue. If you use something like LiveHeaders (Firefox, there are probably equivalents for other browsers) do all four URLs report 301 responses? If so, what are they all getting redirected to? 1 and 2 can't redirect to each other, or you'd be getting an infinite loop.

SunnyG



 
Msg#: 4611178 posted 7:46 am on Sep 21, 2013 (gmt 0)

Thanks lucy24 for taking time to answer my query.

But what I really want to know is whether it's a redirect issue or a tool issue. If you use something like LiveHeaders (Firefox, there are probably equivalents for other browsers) do all four URLs report 301 responses? If so, what are they all getting redirected to? 1 and 2 can't redirect to each other, or you'd be getting an infinite loop.


I don't think there's any problem with the Tools because I checked for my other sites and it's fine. Yes 1 and 2 can't redirect each other. But it's showing 301 for all the urls.

Btw one thing I found in htaccess file that there's no redirection code for domain but for blog of the same [domain.com/blog.html].

Do I need to write 301 lines there ?

SunnyG



 
Msg#: 4611178 posted 7:48 am on Sep 21, 2013 (gmt 0)

Thanks g1smd for your help.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4611178 posted 9:12 am on Sep 21, 2013 (gmt 0)

Do I need to write 301 lines there ?

Heavens, no, if there are that many special cases you're better off rewriting to a--

Whoops! That was actually an old joke of jdMorgan's. I've paraphrased.

Does your htaccess file contain RewriteRules? I'm guessing yes, if you're using any kind of CMS for your blog.

Another possibility is that your host is redirecting. Some offer this as an option for domain names. If so, the redirect won't be visible in your local htaccess files because it's done at the config level. Check your hosting control panel; name and details depend on host, but there's generally something.

Once you start making your own RewriteRules, turn off any host-level options and shift them to your own htaccess instead. Otherwise you risk some requests getting redirected twice, because the host's generic rule will kick in before your specific ones.

SunnyG



 
Msg#: 4611178 posted 10:14 am on Sep 26, 2013 (gmt 0)

Sorry guys I forget to mention a very important point that site is in Wordpress.

Will that make any difference?

Pls. help.

Thanks

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4611178 posted 10:45 am on Sep 26, 2013 (gmt 0)

The important thing about WordPress-- or any other major CMS-- is that it comes with its own htaccess file, mainly involving a lot of rewriting. So if you're making changes of your own, you have to be VERY careful to put your new rules in the right places, where they won't conflict with the existing rules.

SunnyG



 
Msg#: 4611178 posted 12:00 pm on Oct 9, 2013 (gmt 0)

I am still unable to solve !
Can anyone tell me precisely how to solve this problem ?
I shall be thankful if you explain stepwise.

Thanks
Sunny

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4611178 posted 2:55 pm on Oct 9, 2013 (gmt 0)

Let's see what code you already have.

This question has been covered more than 500 times since this forum started so there's no shortage of previous examples.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4611178 posted 10:40 pm on Oct 9, 2013 (gmt 0)

this forum

This is the Website Technology forum ;)

Sunny, you probably do want the Apache subforum. It's right next door. The same people will see your question, but you can start by looking at some of the earlier posts. Look especially at anything involving WordPress or some other CMS that has a ready-made htaccess.

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4611178 posted 9:15 am on Oct 10, 2013 (gmt 0)

while you're under the hood you might want to look at this - How To Speed Up WordPress:
http://www.webmasterworld.com/apache/4502109.htm [webmasterworld.com]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved