Welcome to WebmasterWorld Guest from 54.198.147.221

Forum Moderators: Ocean10000 & incrediBILL & phranque

Change website directory - redirect problem

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

New User

Top Contributors Of The Month

joined:Feb 8, 2016
posts:39
votes: 0


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?
1:50 pm on Mar 31, 2017 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10888
votes: 72


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?
4:34 pm on Mar 31, 2017 (gmt 0)

New User

Top Contributors Of The Month

joined:Feb 8, 2016
posts:39
votes: 0


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
4:49 pm on Mar 31, 2017 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:3332
votes: 162


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]
4:54 pm on Mar 31, 2017 (gmt 0)

New User

Top Contributors Of The Month

joined:Feb 8, 2016
posts:39
votes: 0


If I use that, replacing example.com with my website, will that stop the redirect?
5:54 pm on Mar 31, 2017 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:3332
votes: 162


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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members