Forum Moderators: phranque

Message Too Old, No Replies

Why is Google Giving me an Error When There is a Proper 301 Redirect?

.htaccess problem. error 404 not found even when there a proper redirect.

         

SESeskiz

7:49 pm on May 21, 2012 (gmt 0)

10+ Year Member



I had a folder in my site called Sitemap then in that folder i had sitemap.html and sitemap.xml. Then i moved the files from the folder, deleted the folder and had the sitemap.html and sitemap.xml sit in my main root directory. Then i did a permanent .htaccess 301 redirect. Redirected the files in the sitemap folder out of the folder.

I'm sure I wrote a correct code for the redirect. Now the thing is Google is giving me 404 not found on the sitemap/sitemap.html and sitemap/sitemap.xml (The files that used to be in the folder "sitemap" deleted)
I don't understand why is Google giving me an error if there is a proper redirect?

HERE IS A SCREENSHOT OF THE REDIRECT CODE
<snip>

This is the file on my computer. I have the same file on the server.

This are the other urls redirected and they all work fine. I used the same technical redirecting the sitemap.html and sitemap.xml. The other urls are working fine but why isnt this one?

[edited by: incrediBILL at 10:40 pm (utc) on May 21, 2012]
[edit reason] screenshots not allowed, please post actual code [/edit]

g1smd

8:03 pm on May 21, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Check the responses with the "Live HTTP Headers for Firefox" extension.

incrediBILL

10:42 pm on May 21, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



@SESeskiz please post the actual code in this thread so we can assist. We don't allow links to code located elsewhere or screen shots so that in the future the code is in the thread to help others, long after that screen shot is probably "404 not found".

SESeskiz

5:40 am on May 22, 2012 (gmt 0)

10+ Year Member



Yes sure...

This is the acual redirect code in my .htaccess file

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com /$1 [r=301,nc,L] (<---there is no space in acual file between my domain and /$1, I put a space so google wont fallow my domain and /$1)

Redirect 301 /services_of_amberd_design_studio.html http://www.example.com/services.html
Redirect 301 /portfolio_digital_illustration9_amberd_design_studio.html http://www.example.com/art_gallery/vector_illustrations.html
Redirect 301 /portfolio_digital_illustration6_amberd_design_studio.html http://www.example.com/art_gallery/vector_illustrations.html
Redirect 301 /logo_design_amberd_design_studio.html http://www.example.com/portfolio/logo_design_portfolio.html
Redirect 301 /greeting_cards_amberd_design_studio.html http://www.example.com/portfolio/graphic_design_portfolio.html
Redirect 301 /flyers_postcards_amberd_design_studio.html http://www.example.com/portfolio/graphic_design_portfolio.html
Redirect 301 /doorhangers_signs_amberd_design_studio.html http://www.example.com/portfolio/graphic_design_portfolio.html
Redirect 301 /digital_illustrations_of_emin_sinanyan.html http://www.example.com/art_gallery/vector_illustrations.html
Redirect 301 /contact_amberd_design_studio.html http://www.example.com/contact.html
Redirect 301 /cd_dvd_amberd_design_studio.html http://www.example.com/portfolio/graphic_design_portfolio.html
Redirect 301 /services_of_amberd_design_studio.html http://www.example.com/services.html
Redirect 301 /photo_manipulations2_of_emin_sinanyan.html http://www.example.com/art_gallery/photo_manipulations.html
Redirect 301 /index_amberd_design_studio.html http://www.example.com/index.html
Redirect 301 /graphic_design_amberd_design_studio.html http://www.example.com/portfolio/graphic_design_portfolio.html
Redirect 301 /art_gallery_of_emin_sinanyan.html http://www.example.com/art_gallery/index.html
Redirect 301 /web_design_amberd_design_studio.html http://www.example.com/portfolio/website_design_portfolio.html
Redirect 301 /portfolio_digital_illustration_amberd_design_studio.html http://www.example.com/art_gallery/vector_illustrations.html
Redirect 301 /photo_manipulations_of_emin_sinanyan.html http://www.example.com/art_gallery/photo_manipulations.html
Redirect 301 /paintings_of_emin_sinanyan.html http://www.example.com/art_gallery/paintings.html
Redirect 301 /business_cards_amberd_design_studio.html http://www.example.com/portfolio/graphic_design_portfolio.html
Redirect 301 /web_design_amberd_design_studio.html http://www.example.com/web_design_amberd_design_studio.html
Redirect 301 /portfolio_digital_illustration5_amberd_design_studio.html http://www.example.com/art_gallery/vector_illustrations.html
Redirect 301 /quote_amberd_design_studio.html http://www.example.com/free_quote.html

Redirect 301 /sitemap/sitemap.html http://www.example.com/sitemap.html
Redirect 301 /sitemap/sitemap.xml http://www.example.com/sitemap.xml

Redirect 301 /portfolio/services.html http://www.example.com/services.html
Redirect 301 /sketches_drawings_of_emin_sinanyan.html http://www.example.com/art_gallery/sketches.html
Redirect 301 /self_painings_of_emin_sinanyan.html http://www.example.com/art_gallery/self_portraits_of_emin_sinanyan.html
Redirect 301 /art_gallery_animation/animations_of_emin_sinanyan.html http://www.example.com/art_gallery/animation.html
Redirect 301 /digital_paintings_of_emin_sinanyan.html http://www.example.com/art_gallery/digital_paintings.html
Redirect 301 /slideshow/illustrations/digital_illustrations_of_emin_sinanyan.html http://www.example.com/art_gallery/vector_illustrations.html
Redirect 301 /portfolio/graphic_design_port.. http://www.example.com/portfolio/graphic_design_portfolio.html
Redirect 301 /test.html http://www.example.com/contact.html
Redirect 301 /portfolio/graphic-d http://www.example.com/portfolio/graphic-design-portfolio.html
Redirect 301 /art_gallery/digital_paintings.html http://www.example.com/art-gallery/digital-paintings.html
Redirect 301 /art_gallery/photo_manipulations.html http://www.example.com/art-gallery/photo-manipulations.html
Redirect 301 /art_gallery/self_portraits_of_emin_sinanyan.html http://www.example.com/art-gallery/self-portraits-of-emin-sinanyan.html
Redirect 301 /art_gallery/vector_illustrations.html http://www.example.com/art-gallery/vector-illustrations.html
Redirect 301 /free_quote.html http://www.example.com/free-quote.html
Redirect 301 /portfolio/graphic_design_portfolio.html http://www.example.com/portfolio/graphic-design-portfolio.html
Redirect 301 /portfolio/website_design_portfolio.html http://www.example.com/portfolio/website-design-portfolio.html
Redirect 301 /portfolio/logo_design_portfolio.html http://www.example.com/portfolio/logo-design-portfolio.html
Redirect 301 /social_media.html http://www.example.com/social-media.html
Redirect 301 /history_of_the_fortress_of_amberd.html http://www.example.com/about.html
Redirect 301 /portfolio/portfolio/portfolio.html http://www.example.com/portfolio/index.html
Redirect 301 /portfolio_of_amberd_design_studio.html http://www.example.com/portfolio/index.html
Redirect 301 /art-gallery/art_gallery_of_emin_sinanyan.html http://www.example.com/art-gallery/index.html
Redirect 301 /po http://www.example.com/portfolio/index.html

[edited by: incrediBILL at 8:48 pm (utc) on May 22, 2012]
[edit reason] fixed URLS, use Example.com [/edit]

SESeskiz

5:45 am on May 22, 2012 (gmt 0)

10+ Year Member



Problem fixed. How can i delete this post now?

g1smd

6:39 am on May 22, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You might think it's fixed, but there are a ton of problems with that code.

Additionally, the code snipppet is unreadable as you failed to follow the simple instuctions in the sticky thread.

SESeskiz

6:51 am on May 22, 2012 (gmt 0)

10+ Year Member



Which instracctions are you talking about? This Check the responses with the "Live HTTP Headers for Firefox" extension.

I tried but the addon did not work for my firefox

g1smd

8:32 am on May 22, 2012 (gmt 0)

lucy24

10:35 pm on May 22, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



(<---there is no space in acual file between my domain and /$1, I put a space so google wont fallow my domain and /$1)

?
I hope you mean that you put the space in the post, not in your htaccess. I have just this second-- really-- finished composing a post stressing that a space has semantic meaning in many Apache modules, including mod_rewrite and mod_alias. The space would not have been necessary if poor Bill hadn't had to keep running around behind you changing everything to example dot com.

I also gotta point out that Apache is very, very unforgiving. Humans can generally work out what's behind a typo. Apache is completely clueless. A single "RewriteRuel" and the whole thing comes crashing to the ground.

And speaking of Rewrite and Redirect...

Once you've got a single rule using mod_rewrite, you have to change all your mod_alias ("Redirect" by that name) rules to use mod_rewrite instead. If you have a text editor that does Regular Expressions, you can change them all with 2 or 3 global replaces. I've posted the formula a couple of times. You can get away with using both mods if it is your own server so you know exactly what executes before what. Otherwise, don't take chances.

Now then... Redirecting to sitemap.xml in the root directory should not even be necessary, because that is where search engines will look for it by default-- especially if you also have a "Sitemap" line in your robots.txt. Sure, g### will keep looking in the old location. But they'll also check the generic location; they've probably been looking there all along.

g1smd

10:55 pm on May 22, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can make things a lot more efficient. For example:

Redirect 301 /sitemap/sitemap.html http://www.example.com/sitemap.html
Redirect 301 /sitemap/sitemap.xml http://www.example.com/sitemap.xml


simplifies to:

RewriteRule ^sitemap/sitemap\.(ht|x)ml http://www.example.com/sitemap.$1ml [R=301,L]


-----

Redirect 301 /po http://www.example.com/portfolio/index.html


You should not redirect to a named index file. The canonical URL for a folder or the index page in a folder should end with a trailing slash.

RewriteRule ^po$ http://www.example.com/portfolio/ [R=301,L]