Stop Rewrite htaccess create random pages
Posted
by
Vistol
on Stack Overflow
See other posts from Stack Overflow
or by Vistol
Published on 2012-11-28T11:02:30Z
Indexed on
2012/11/28
11:03 UTC
Read the original article
Hit count: 192
.htaccess
|url-rewriting
Recently I saw in my Webmaster tools that some random sites are linking to my site. Actually this is not an big issue. The issue comes when the pages that are linked are not real pages because of my httaccess file.
This is the htaccess code that Im running:
<pre>
#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ index.php?id=$1 [L]
RewriteRule ^([0-9]+)/(.*)$ index.php?id=$1 [L]
</pre>
So the real URLs would be:
mysite.com/folder/999/TITLE-OR-NAME
But cecause I only check the 1st folder ($1) which is an I numberD, this htaccess file is allowing hackers linking to my site with random URLs like:
mysite.com/folder/999/TITLE-OR-NAME1
mysite.com/folder/999/TITLE-OR-NAME2
mysite.com/folder/999/TITLE-OR-NAME3
mysite.com/folder/999/TITLE-OR-NAME4
mysite.com/folder/999/TITLE-OR-NAME5
The worst part comes when google tells me that I am duplicating content!!!
Actually I am not duplicating content, the htaccess is duplicating it for me. And yes I know, Im a bad newbie programmer but Id really appreciate your help with this cause Im struggling to find a solution but it never.
Thank you very much for all your support to this newbie :)
© Stack Overflow or respective owner