• RewriteEngine on
    RewriteRule ^ – [E=rewrite:on]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^devel/test/static/life/Non-Smoking_Campus.pdf$ /devel/test/static/wp-content/uploads/Non-Smoking_Campus.pdf [R=301,L]

    RewriteCond %{ENV:rewrite} !on
    RewriteRule ^ – [L,R=404]

    I keep getting a 404 error.
    It’s on SiteGround and I’ve flushed the cache repeatedly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The line

    RewriteRule ^ – [L,R=404] 

    is basically telling the server to return a 404 error for everthing

    What are you trying to do with the redirects and maybe I can help or point you in the right direction?

    • This reply was modified 1 year, 2 months ago by pichichi.
    Thread Starter TWD

    (@twd)

    If I understand correctly, putting “L” at the end of:
    RewriteRule ^devel/test/static/life/Non-Smoking_Campus.pdf$ /devel/test/static/wp-content/uploads/Non-Smoking_Campus.pdf [R=301,L]

    means “if this rule executes, make it the LAST rule.
    i.e. every rule after that one is ignored.

    So if the rule is activated this rule doesn’t get applied.
    RewriteRule ^ – [L,R=404]

    Or am I mistaken?

    Moderator bcworkz

    (@bcworkz)

    Last rule for that request. But executing a rewrite causes a new request and .htaccess is processed all over again. This time the R=404 is encountered.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘What’s wrong with this simple .htaccess file’ is closed to new replies.