Forum Moderators: phranque

Message Too Old, No Replies

Change website directory - redirect problem

         

faceman

12:41 pm on Mar 31, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



I tried to change the directory of my site last night but found it was impossible due to a 301 redirect that I've used for the past 13 years.

I wanted to move my site into root from /site. But whenever I remove the 301 redirect that is present in a htaccess file in root, nothing changes and it still redirects.

It did work when I was in a private window, and after clearing cache but I can't expect every visitor to my site to know to do that, so I had to revert back. Am I stuck with this now?

phranque

1:50 pm on Mar 31, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It did work when I was in a private window, and after clearing cache but I can't expect every visitor to my site to know to do that, so I had to revert back. Am I stuck with this now?


definitely a cached response problem...
what Cache-Control or Expires headers values are you sending with the response?

faceman

4:34 pm on Mar 31, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



I don't think I have any set. This is what my ht access looks like now (I changed it to a temporary redirect instead though now), it is just the standard redirect set up in cpanel

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mysite\.co\.uk$
RewriteRule ^/?$ "https\:\/\/www\.mysite\.co\.uk\/site\/" [R=302,L]

I have htaccess headers set in a htaccess file in the /site directory though

not2easy

4:49 pm on Mar 31, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I would set it up properly in htaccess and get rid of the one in cpanel. The rules as posted above are not formatted correctly, the target should not be escaped, and those 302s should be avoided. The ruleset does not need to rewrite www to www. A more standard ruleset would be:
#Redirect invalid and non www requests
RewriteCond %{HTTP_HOST} !^(www\.example\.com)$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

faceman

4:54 pm on Mar 31, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



If I use that, replacing example.com with my website, will that stop the redirect?

not2easy

5:54 pm on Mar 31, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Sorry, that only addresses the format, you would need an additional line to redirect requests for /site/ to root. I don't have my files at hand to help more right now, using mobile. There are a lot of helpful examples if you click on the Forum Options Button and check out the Library.