Forum Moderators: phranque

Message Too Old, No Replies

Exclude One URL Only From htaccess Rules

         

actolearn

4:40 pm on Jul 2, 2014 (gmt 0)

10+ Year Member



Hello ~

Below are the two Rules at bottom of my htaccess file but I need to EXCLUDE the
pinterest url from my rules because pinterest doesn't use WWW.

Their button code for me is (minus the astrisks)
**http://pinterest.com/example/

but REDIRECTING TO:
**http://www.pinterest.com/example/


#31 index.html hidden on home page url
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html http://www.example.com/$1 [R=301,L]

#32 all non www to www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
................


Any help would be appreciated. I did a search for exclusions and found everything but
what I need ....

not2easy

6:07 pm on Jul 2, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



The rules you have here do not rewrite external links so they do not include URLs on other domains. The www. is getting added at pinterest whether they intended that or not. Actually, if you copy the pinterest URL shown in your button into your browser's address bar it automatically becomes [www...] not just www.

Maybe check to see if they offer a new version for your button?

lucy24

7:31 pm on Jul 2, 2014 (gmt 0)

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



I need to EXCLUDE the
pinterest url from my rules because pinterest doesn't use WWW.

Completely backward. If they ask for the wrong form of your hostname, FORCE them to go to the correct form. Doesn't matter if they're pinterest, google, the NSA or your mother. If their current code doesn't allow for leading "www." in their links, that's their problem, not yours. Human users will never notice.

not2easy

8:43 pm on Jul 2, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



OK, this part:
Their button code for me is (minus the astrisks)
**http://pinterest.com/example/

but REDIRECTING TO:
**http://www.pinterest.com/example/
looks to me like the button is linking TO Pinterest from the OP's domain. It is a paste in code that Pinterest offers so webmasters can give people a simple way to let people pin their content. It links to Pinterest from the OP's domain, therefore the OP's htaccess file isn't what converts it to www, it is pinterest's htaccess. But I could be wrong.

lucy24

9:14 pm on Jul 2, 2014 (gmt 0)

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



Whoops! And if you're reading that right, then the OP's htaccess is irrelevant, because the redirect-- or anything else in htaccess-- applies to incoming requests, not outgoing ones.

Is it possible someone's getting confused by exemplifying? When a quoted rule in these forums says "example.com" it doesn't mean "do this to all domains everywhere". It means "I've used 'example' to camouflage my own name".

actolearn? What's going on?

actolearn

12:03 am on Jul 3, 2014 (gmt 0)

10+ Year Member



Thanks for your responses. Just getting back to the boards. HEAVY lightning here for the last few hours so had pc unplugged (just in case).

Anyway, the example.com was used merely for these boards. I also just added the astrisks so that it's easier to see plus I noticed that when I didn't add the astrisks the link actually pointed to someone named Linda which is not me. Don't know why and don't even want to think about that for now.

The partial Pinterest code in my original post is from a Pinterest button code I have in my website footer so people can go to my Pinterest Boards and follow me.

Everything works fine but when checking my site with a link validator it indicates "This is a permanent redirect but should be updated/needs to link to final location".

http://pinterest.com/example/ redirected to 
http://www.pinterest.com/example/


I still feel this is happening because of what I have in my htaccess file about all non-www's redirecting to www's. No?

[edited by: incrediBILL at 5:57 am (utc) on Jul 3, 2014]
[edit reason] formatting [/edit]

actolearn

12:07 am on Jul 3, 2014 (gmt 0)

10+ Year Member



OK, this part:
Their button code for me is (minus the astrisks)
**http://pinterest.com/example/

but REDIRECTING TO:
**http://www.pinterest.com/example/
looks to me like the button is linking TO Pinterest from the OP's domain. It is a paste in code that Pinterest offers so webmasters can give people a simple way to let people pin their content. It links to Pinterest from the OP's domain, therefore the OP's htaccess file isn't what converts it to www, it is pinterest's htaccess. But I could be wrong.


Yes, this is what I was trying to say about the code ....

actolearn

12:17 am on Jul 3, 2014 (gmt 0)

10+ Year Member



The rules you have here do not rewrite external links so they do not include URLs on other domains. The www. is getting added at pinterest whether they intended that or not.


I understand above but what I'm asking is:
Does what I have in my htaccess file re non-www's to www's causing the extra loop?

Sorry - I'm absolutely horrible at explaining myself.

lucy24

12:42 am on Jul 3, 2014 (gmt 0)

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



I still feel this is happening because of what I have in my htaccess file about all non-www's redirecting to www's. No?
...
Does what I have in my htaccess file re non-www's to www's causing the extra loop?

No, absolutely not, in no way at all, flatly impossible. Your htaccess file only affects requests for pages on your site. It has no effect on (1) other people's sites or (2) the content of your pages.

When someone clicks on an outbound link in one of your pages, that new request never comes within a mile of your htaccess.

when checking my site with a link validator it indicates "This is a permanent redirect but should be updated/needs to link to final location".

That means your own HTML is wrong and needs to be corrected.

Now, if you're using copy-and-paste that was originally provided to you by pinterest, and their own boilerplate points to the wrong form of their own domain name ... Well, that's pretty funny, but still not your problem. Fix your code if you can readily do so. Otherwise don't sweat it.

actolearn

1:56 am on Jul 3, 2014 (gmt 0)

10+ Year Member



Ok, I get it now - I'm not thinking this out correctly. I understand now. Will try to figure out what else it could be and come back tomorrow if have more questions.

Thx all!

not2easy

2:24 am on Jul 3, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Or just change your button to www and see where it goes. For me, it goes to [www...] (at their end, without ever seeing your button) That's why I suggested to visit Pinterest and see if maybe they have updated the button code you should use. The unintended link might be where your button does go, it takes some test clicks to see what is happening.

actolearn

3:41 pm on Jul 4, 2014 (gmt 0)

10+ Year Member



Thank you, not2easy. This worked and was so easy I would never have thought of it...(sigh).