skip to Main Content

slightly weird issue here I cant get my head around.

So ive been playing around with my .htaccess file in an extremely amateurish way. I successfully added a simple 301 redirect from one URL to another. However I have since deleted this instruction and the redirection still occurs.

To comfound matters I added another rule into the file and this was not being executed. I tried deleting the file. This stopped the initial 301 redirect from occuring (even though the instruction was not in the file).

I readded the .htcaccess file and added my new rule, this now works but the original 301 redirection is still occuring.

this is really befuddling me, if anyone has any idea what is going on here help would be appreciated.

Im running plesk 12 if that makes any difference.

So now my .htaccess file looks like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301,NC]

however my url /pages/page still 301 redirects to /page (even though there is obviously not a rule in there anymore for this)

2

Answers


  1. One way to debug issues like this is to enabled logging for mod rewrite, for example adding LogLevel info rewrite:trace5 in httpd.conf and tailing the apache error log to see how apache is processing the rewrite rules. Documentation on log files: https://httpd.apache.org/docs/2.4/logs.html, see Per-Module logging section.

    Login or Signup to reply.
  2. Pay attention that web browsers are aggressively caching redirect 301.

    Btw, if you just need simple redirect domain.tld to www.domain.tld there is special option “Preferred domain” in hosting settings:

    plesk-301-redirect-htaccess

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search