• Due to some SPAM issue my site get hammered with requests for now dead links, there where a few 1000 links. So many that it slows down the shared server a lot and makes the site very slow. Every hit triggers a WordPress “page not found”.

    I am on a cPanels shared host with Litespeed. The logical way would be to let Apache handle it through some HTACCESS lines and point all 404 to a i.e. 404.html page OUTSIDE of WordPress.

    But whatever I do either nothing happens, or all requests go to that 404.html page. Usually nothing happens.

    This is my original .htaccess

    <IfModule LiteSpeed>
    RewriteEngine on
    CacheLookup on
    RewriteRule .* - [E=Cache-Control:no-autoflush]
    RewriteRule \.litespeed_conf\.dat - [F,L]
    RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php - [E=cache-control:max-age=3600]
    RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
    CacheKeyModify -qs:fbclid
    CacheKeyModify -qs:gclid
    CacheKeyModify -qs:utm*
    CacheKeyModify -qs:_ga
    </IfModule>
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    <IfModule mime_module>
      AddHandler application/x-httpd-alt-php74 .php .php7 .phtml
    </IfModule>
    
    <IfModule LiteSpeed>
    php_value auto_prepend_file '/home/myshared/public_html/wpraw/wordfence-waf.php'
    </IfModule>
    
    <IfModule lsapi_module>
    php_value auto_prepend_file '/home/myshared/public_html/wpraw/wordfence-waf.php'
    </IfModule>
    
    <Files ".user.ini">
    <IfModule mod_authz_core.c>
    	Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
    	Order deny,allow
    	Deny from all
    </IfModule>
    </Files>

    What I tried so far:

    ErrorDocument 404 /404.html
    #not sure where to exactly need to place that
    

    and

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /404.html [L]

    I have 404 in html, php and shtml, with path, with URL and just text, like: ErrorDocument 404 "No bots allowed!"

    How can I make a server 404 redirect work?

    • This topic was modified 3 years, 3 months ago by yellofish.
    • This topic was modified 3 years, 3 months ago by yellofish.
    • This topic was modified 3 years, 3 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
Viewing 2 replies - 1 through 2 (of 2 total)
  • Did you try with a plugin instead of editing the .htaccess file?

    https://www.ads-software.com/plugins/redirection/

    Thread Starter yellofish

    (@yellofish)

    Thanks for the reply. Well, yes and no. I try that app again.

    The plugin can redirect a SPAM URL to an outside-WP-page (or basically any URL), however, you need to make each redirect individually (or in groups of 25). It seems that the redirection is handled by WordPress rather than the server, putting load on WordPress – or looks like that.

    One annoyance is that the “select all” function and the the delete seem to work very buggy and you need to reload a lot.

    Will monitor it for a while and hope that Cloudflare will pick up those links.

    • This reply was modified 3 years, 3 months ago by yellofish.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to redirect 404 directly on (shared) server?’ is closed to new replies.