Forum Moderators: phranque

Message Too Old, No Replies

To http://www or not? (http://)

http://www.widgets.com or http://widgets.com?

         

explorador

5:47 pm on May 8, 2011 (gmt 0)

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



I'm using htaccess on one of my sites to redirect all the [www....] widgets. com to http:// widgets.com removing the www, why? to make my life easier redirecting pages withing one one app and also make easier the cookie handling, so, there are no variations on the urls.

Testing G Webmaster Tools, seeing the site as gooble bot sees it, I get the results as "301 moved permanently" for every www page. Yes I know, the htaccess is causing that because I make it that way. Should I worry? Visiting pages with google but using http without www returns the content instead.

Removing the htaccess will make Gbot to read the page at once on the first try, keeping it causes a redirection every time, double work?

I remember an old reading about using redirects to avoid some sort of duplicates on search engines, I also recall there was some discussion about it as it caused more work and the bots not seeing the content right away.

I will be glad to read your opinions about this on a search engine benefits/problems point of view. Thanks in advance.

Searched for this but couldn't find any not too old discussion about it, just tech questions on how to do it.

g1smd

6:03 pm on May 8, 2011 (gmt 0)

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



Make sure that all site-internal links point to the correct URL.

Clicking an internal link should never result in a redirect within the site.

explorador

3:20 am on May 9, 2011 (gmt 0)

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



Thanks g1smd, now that I think about it, I only need to redirect the urls used by the admin section (won't ever be public or visible to the SEs). I could achieve this using a mapping only for specific file extensions (the ones the admin section use).

After some hours of reading and testing (msut confess, htaccess is kidna cryptic for me) I came up with this:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^([a-zA-Z0-9]+).app$ [%1...] [R=301,L]
... other mappings
... and other mappings...
etc...


It works and removes the WWW and redirects to http (without www's) just as I want to, but this time ONLY FOR files with .app extension on the top directory (much better). After reading other examples of htaccess stating that -in fact worked- but had issues of performance and speed, I would appreciate if someone could tell me if the previous code represents any problem. There won't be any complicated filenames with underscores or signs (client-login.app), it will be just plain single words (login.app)

Thanks in advance

g1smd

7:20 am on May 9, 2011 (gmt 0)

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



You need to repeat RewriteCond for each RewriteRule.

You need to escape the literal period in the RegEx pattern.

explorador

3:49 pm on May 9, 2011 (gmt 0)

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



Thanks g1smd,

didn't know about that (repeating RewriteCond for each RewriteRule), I based my file on examples and it worked, but I know that "it works" doesn't always mean it works as it should, I modified the code based on your suggestion, I came up with the following: repeating the RewriteCond and scaping the period on the regex, could you please take a look and tell me if some, all or just one are right, wrong? (added line #s to make easier to point out errors).



1. Options +FollowSymLinks
2. RewriteEngine On
3. RewriteCond %{HTTP_HOST} ^www\.(.*)
4. RewriteRule ^([a-zA-Z0-9]+)\.app$ [http://%1/$1\.app] [R=301,L]
5. RewriteRule ^([a-zA-Z0-9]+).login$ cgi-bin/sys/login.pl?$1 [L,NC]
6. RewriteRule ^([a-zA-Z0-9]+).app$ cgi-bin/core/safecheck.pl?$1 [L,NC]
7. RewriteRule ^([a-zA-Z0-9]+).js$ cgi-bin/core/parsejs.pl?$1 [L,NC]
8. RewriteRule ^rss.html$ cgi-bin/core/rss.pl [L,NC]
9. RewriteRule ^search.bs$ cgi-bin/core/search.pl [L,NC]
10. RewriteRule ^advsearch.bs$ cgi-bin/core/advsearch.pl [L,NC]
11. RewriteRule ^contact.bs$ cgi-bin/core/contact.pl [L,NC]



 1. Options +FollowSymLinks
2. RewriteEngine On

3. RewriteCond %{HTTP_HOST} ^www\.(.*)
4. RewriteRule ^([a-zA-Z0-9]+)\.app$ [http://%1/$1\.app] [R=301,L]

5. RewriteCond %{HTTP_HOST} ^www\.(.*)
6. RewriteRule ^([a-zA-Z0-9]+).login$ cgi-bin/sys/login.pl?$1 [L,NC]

7. RewriteCond %{HTTP_HOST} ^www\.(.*)
8. RewriteRule ^([a-zA-Z0-9]+).app$ cgi-bin/core/safecheck.pl?$1 [L,NC]

9. RewriteCond %{HTTP_HOST} ^www\.(.*)
10. RewriteRule ^([a-zA-Z0-9]+).js$ cgi-bin/core/parsejs.pl?$1 [L,NC]

11. RewriteCond %{HTTP_HOST} ^www\.(.*)
12. RewriteRule ^rss.html$ cgi-bin/core/rss.pl [L,NC]

13. RewriteCond %{HTTP_HOST} ^www\.(.*)
14. RewriteRule ^search.bs$ cgi-bin/core/search.pl [L,NC]

15. RewriteCond %{HTTP_HOST} ^www\.(.*)
16. RewriteRule ^advsearch.bs$ cgi-bin/core/advsearch.pl [L,NC]

17. RewriteCond %{HTTP_HOST} ^www\.(.*)
18. RewriteRule ^contact.bs$ cgi-bin/core/contact.pl [L,NC]




1. Options +FollowSymLinks
2. RewriteEngine On

3. RewriteCond %{HTTP_HOST} ^www\.(.*)
4. RewriteRule ^([a-zA-Z0-9]+)\.app$ [http://%1/$1\.app] [R=301,L]

5. RewriteCond %{HTTP_HOST} ^www\.(.*)
6. RewriteRule ^([a-zA-Z0-9]+)\.login$ cgi-bin/sys/login\.pl?$1 [L,NC]

7. RewriteCond %{HTTP_HOST} ^www\.(.*)
8. RewriteRule ^([a-zA-Z0-9]+)\.app$ cgi-bin/core/safecheck\.pl?$1 [L,NC]

9. RewriteCond %{HTTP_HOST} ^www\.(.*)
10. RewriteRule ^([a-zA-Z0-9]+)\.js$ cgi-bin/core/parsejs\.pl?$1 [L,NC]

11. RewriteCond %{HTTP_HOST} ^www\.(.*)
12. RewriteRule ^rss\.html$ cgi-bin/core/rss\.pl [L,NC]

13. RewriteCond %{HTTP_HOST} ^www\.(.*)
14. RewriteRule ^search\.bs$ cgi-bin/core/search\.pl [L,NC]

15. RewriteCond %{HTTP_HOST} ^www\.(.*)
16. RewriteRule ^advsearch\.bs$ cgi-bin/core/advsearch\.pl [L,NC]

17. RewriteCond %{HTTP_HOST} ^www\.(.*)
18. RewriteRule ^contact\.bs$ cgi-bin/core/contact\.pl [L,NC]