Welcome to WebmasterWorld Guest from 54.221.28.179

Forum Moderators: phranque

Message Too Old, No Replies

301 Redirection

     

SunnyG

6:41 am on Sep 20, 2013 (gmt 0)

5+ Year Member



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

7:02 am on Sep 20, 2013 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

9:42 am on Sep 20, 2013 (gmt 0)

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



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

7:46 am on Sep 21, 2013 (gmt 0)

5+ Year Member



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

7:48 am on Sep 21, 2013 (gmt 0)

5+ Year Member



Thanks g1smd for your help.

lucy24

9:12 am on Sep 21, 2013 (gmt 0)

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



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

10:14 am on Sep 26, 2013 (gmt 0)

5+ Year Member



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

Will that make any difference?

Pls. help.

Thanks

lucy24

10:45 am on Sep 26, 2013 (gmt 0)

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



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

12:00 pm on Oct 9, 2013 (gmt 0)

5+ Year Member



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

2:55 pm on Oct 9, 2013 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

10:40 pm on Oct 9, 2013 (gmt 0)

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



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

9:15 am on Oct 10, 2013 (gmt 0)

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



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]
 

Featured Threads

Hot Threads This Week

Hot Threads This Month