Forum Moderators: phranque

Message Too Old, No Replies

301 Redirect NOT working for multiple pages

         

anniez

8:29 pm on Dec 23, 2010 (gmt 0)

10+ Year Member



Hello, newbie here. Very, very new webmaster. Well, upon reading the posts, I was able to successfully redirect one page, so thank you! But I am having trouble with the other pages, Please help if you can.

My redirect for my "about" page is working since it is the first one listed. My other page redirects are NOT working. I am so confused.

We use Go Daddy, Microsoft Front Page, I created the .htaccess file with notepad and only the "About" page is redirecting....? Why are the other pages not redirecting? Something is wrong with the code, spacing?

Here's my "code"...

redirect 301 /About.html http://www.mysite.com/about.html 
redirect 301 /Gallery%20I.html http://www.mysite.com/gallery_one.html
redirect 301 /Gallery%20II.html http://www.mysite.com/gallery_two.html
redirect 301 /Gallery%20III.html http://www.mysite.com/gallery_three.html
redirect 301 /Services.html http://www.mysite.com/services.html
redirect 301 /QandA.html http://www.mysite.com/faq.html
redirect 301 /Contact.html http://www.mysite.com/contact.html
redirect 301 /Links.html http://www.mysite.com/videos.html

anniez

9:35 pm on Dec 23, 2010 (gmt 0)

10+ Year Member



Update: all are now working and redirecting except the Gallery pages... :(

redirect 301 /Gallery%20I.html http://www.mysite.com/gallery_one.html
redirect 301 /Gallery%20II.html http://www.mysite.com/gallery_two.html
redirect 301 /Gallery%20III.html http://www.mysite.com/gallery_three.html


I'm guessing it has to do with the file names

Before I renamed them, I saved the html documents as Gallery I, Gallery II, Gallery III
but when they uploaded,
they uploaded as Gallery%20I.html, Gallery%20II.html, etc

What can I do to redirect these 3 pages?

anniez

10:15 pm on Dec 23, 2010 (gmt 0)

10+ Year Member



I fixed it! YAY! Used quotes and literal spaces instead of %20
:)

jdMorgan

3:40 pm on Jan 5, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you found a fix -- Sometimes we're a little slow around here during the holidays.

I would suggest that your code would be more robust if you used RedirectMatch instead of Redirect. RedirectMatch uses regular expressions pattern matching as opposed to Redirect, which uses prefix-string matching. If that isn't clear, it means that your first rule in the post just above will also redirect /Gallery I.html-anything-here to /gallery_one.html-anything-here

So if such a malformed URL is requested from your server, the result will be a 301 redirect followed by a 404-Not Found, when you'd really just want to 404 the original request (for the sake of efficiency and to avoid confusing search engines).

Therefore, using
RedirectMatch 301 ^/Gallery\ I\.html$ http://www.example.com/gallery_one.html

would be a more-robust solution, as it matches only the exact old URL.

However, do be aware that mixing Redirect and RedirectMatch directives from mod_alias with RewriteRule directives from mod_rewrite can cause problems due to module execution order. For this reason, I suggest that if you use mod_rewrite for anything, use it for everything.

So if you do use mod_rewrite for anything else --or might want to in the future-- then
RewriteRule ^Gallery\ I\.html$ http://www.example.com/gallery_one.html [R=301,L]

would be preferred.

Finally, be aware that search engines treat the underscore as a literal character, and therefore using URLs such as gallery_one.html will yield no benefit in searches for the string "gallery." Only searches for the entire string "gallery_one" will give any keyword-in-URL ranking benefit.

Furthermore, underscores can "hide" under link on-page underlining, making it hard to read and/or speak the URL correctly (for example, on the radio or on a phone).

For these reasons, it is generally recommended to use a hyphen instead. Hyphens are treated as lexical spaces by search engines, and they cannot hide under link underlining.

These points have been endlessly discussed here in the search engine and usability forums, but consider them in light of your site and your user-base, and apply them as appropriate.

Jim