Prevent users from replacing hyphens with periods on WordPress sites

After looking at Google Analytics and ad traffic, we realized that people were able to find pages on client sites in a very strange way. Replace hyphens with periods.

For instance...

Correct link: www.domain.com/this-is-a-link Invalid: www.domain.com/this.is.a.link

Both work and send the user to the same page. But I do not know why. We tried different browsers, and it seems they work the same in all of them. Normally this would be useful for the user (generally speaking), but it distorts analytics.

I suspect that the people in the ad campaign created a link with the periods that triggered the problem. But even with fixing this question, he does not answer the question of why this works, or how to prohibit this behavior / functionality.

Any thoughts?

+5
source share
1 answer

Wordpress uses mod_rewrite for permalink. And mod_rewrite uses pattern matching in your urls to distinguish what to rewrite and what not to rewrite in your .htaccess file.

Symbol . actually means any character in the regular express pattern matching, which is what mod_rewrite uses to determine what needs to be rewritten.

to illustrate it better take your example

 www.domain.com/this-is-a-link 

to be the correct link you wish, but in case

 www.domain.com/this.is.a.link 

It will also be appropriate since . reads like - because one dot means any character

you can learn more about mod_rewrite to better understand why a period reads like a dash as well.

The only way to solve this problem is to rewrite the default default mod_rewrite Wordpress template or report it as an error in order to ask the main communities to list it, since the error will be more suitable. But this seems pretty common even with a big site like eBay with url

  http://www.ebay.com/rpp/halloween-events/sweet-treats 

URL with

  http://www.ebay.com/rpp/halloween-events/sweet.treats 

. I believe this is a limitation in mod_rewrite, so you can live with it.

+1
source

All Articles