0

I have to counter bots on a static php website, which randomly creates URLs after.php pages, fake traffic that ruins stats and slows the server down. On wordpress there is for example a nice redirect to homepage plugin which redirects all non-canonical URLs. But i'm using a custom php site, not a CMS. So with htaccess i need to redirect random URLs after any post string .php page to a fixed URL (404 or home) whatever the depth like .php//// etc. Note that valid URLs never has more than 3 levels. Ex. http:home.com/1/2/3.php Thanks !

I tested these for example:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} On
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^/php/([^/]+)\.x?html$ /index.php/$1 [PT]
RewriteCond %{HTTP_HOST} ^www\.home\.com/$1/.php\/* [NC]

RewriteRule (.*) https://home.com/$1 [L,R=301]
or
RewriteEngine on
RewriteCond %{HTTP_HOST} ^home.com/$1/.php/* [NC,OR]
RewriteRule ^(.*)$ http://home.com/$1 [L,R=301,NC]
dbodesign
  • 1
  • 1

0 Answers0