2

I'm French. A week ago, my website was hacked with the old version (http). The hack created 404 spams and I want to ensure they have "410 Gone" status. My problem on the site is: https://www.example.com/aasption

I tried:

RewriteRule ^aasption - [G] 

in the htaccess. It doesn't work. What is going wrong?

UPDATE:

The problem is that I'm still getting a 404.

Example URLs that have been spammed:

  • www.example.com/aasption.asp?id=puma/puma-ambition-collant/prd/9723115?...
  • wwww.example.com/aasption.asp?search=puma&page=5

My .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^aasption - [G]
</IfModule>
1
  • What do you mean by "it doesn't work"? Are you still getting a 404? Or something else? Do you have other directives in your .htaccess file?
    – MrWhite
    Jun 18, 2019 at 18:19

1 Answer 1

2

You've put your directive in the wrong place. It needs to go at the top of the .htaccess file, before the front-controller, not at end. By putting this code at the end, it's simply not going to do anything, because the preceding directives have already rewritten the URL for any request that does not map to a physical file.

The order of these directives is important.

For example:

# Send 410 Gone for any URL that starts "/aasption"
RewriteRule ^aasption - [G]

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

You do not need to repeat the RewriteEngine On directive.

1
  • 1
    If this answered your question then please mark it as accepted (checkmark below the voting arrows on the left) to remove it from the unanswered question queue and to help other readers. Once you have 15+ rep you can also upvote answers you find useful. Thanks, much appreciated. :)
    – MrWhite
    Jun 19, 2019 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.