21

I stupidly did a 301 redirect on websiteA.com to websiteB.com. After removing it from the .htaccess file the redirect is still in operation. I tried from outside the local network and it is still redirecting. I have cleared my cache and tried a different browser.

Does anybody have any suggestions?

UPDATE:

If I add a 302 redirect to this .htaccess file the site honours it. When I remove it, the old 301 redirect still happens.

.htaccess file for websiteA.com:

# -- concrete5 urls start --

Options -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
# -- concrete5 urls end --

#RewriteCond %{HTTP_HOST} ^.*$
#RewriteRule ^/?$ "http\:\/\/www\.websiteB\.co\.uk\/" [R=301,L]
animuson
  • 53,861
  • 28
  • 137
  • 147
beingalex
  • 2,416
  • 4
  • 32
  • 71
  • Post your full .htaccess here. – anubhava Feb 24 '12 at 13:00
  • Nothing obviously wrong in this code, can you check matching lines in your access.log? – anubhava Feb 24 '12 at 13:30
  • Hi :) When I visit the site, one line appears in access log when "tail -f websiteA": 1.1.1.1 - - [24/Feb/2012:13:37:45 +0000] "GET / HTTP/1.1" 301 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2" – beingalex Feb 24 '12 at 13:39
  • It's as if the original 301 permanent redirect is getting cached somewhere. It's not getting cached within my local network because we tried on somebody's mobile using a 3G network. – beingalex Feb 24 '12 at 13:49
  • .htaccess is not cached, I am suspecting that either have some stray .htaccess somewhere in your DOCUMENT_ROOT or your code is doing this redirection. Will it be possible for you to enable RewriteLog and then check the log entries. – anubhava Feb 24 '12 at 13:54
  • I found the problem. I had a base url constant in the config PHP for the site. It had the wrong address in it. Thank you for your assistance anyway. – beingalex Feb 24 '12 at 14:37

6 Answers6

19

Try to visit the website with Developers Console open (F12)

Make sure you check "Disable cache" under "Network" tab

bypass 301 redirect

This will bypass 301 redirect cache on browser-side.

Lucas Bustamante
  • 15,821
  • 7
  • 92
  • 86
17

The browser caches the 301 Moved Permanently, until told otherwise. It is default behavior: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2.

To fix it in IE9:

  1. Open IE9 and press Ctrl+Shift+P for private browsing
  2. Navigate to the problem URL
  3. Then go back to normal browsing and all should be fine again
Filip Cornelissen
  • 3,682
  • 3
  • 31
  • 41
8

Just delete the line about the Redirect.

And also everyone who has Google Chrome, do the following steps:

  1. Press CTRL + SHIFT + DELETE from your keyboard.
  2. Only check -> "Files and images stored in cache"
  3. Select in "Elements stored in cache since: Past week"

That will clear all your cache and you'll be fine.

DarkteK
  • 821
  • 1
  • 15
  • 26
6

The permanent redirect cache is probably in the browser
and in most browsers it is tricky to remove it.
But first, try using a different browser to see if this is the case.

If the cache is in the browser, cleaning the browser data for that website doesn't work.

To remove the redirection, there is a method for each browser:

The lesson
When playing with redirects use [302] first.
After everything was tested ok, change the code to [301]

ePi272314
  • 12,557
  • 5
  • 50
  • 36
0

I know this is an old post but i spent some time on the Web and my server to find the answer.

If you created an .htaccess file with a permanent redirection, the server will copy this redirection in the following file : "/var/.htaccess".

You have to edit this file to remove the redirection before cleaning the cache of your browser.

It worked on my Debian Jessie.

  • I'm not sure whether the absolute path to the file helps the OP and the path you specified is probably not correct (unless your homepage is located in `/var`). – Peanut Jun 09 '15 at 14:59
  • You are right, the path must be /var in this case, thanks –  Aug 22 '15 at 11:30
-1

Try giving Apache a restart

(on Ubuntu servers: service apache restart or /etc/init.d/apache2 restart)

buley
  • 28,032
  • 17
  • 85
  • 106
  • The 301 redirection is stored at each of the users browsers, not the server, so it wouldn't really help. – MasterMastic Feb 06 '13 at 12:45
  • The redirect may be cached at the browser level but it's the server that throws it. That said, an apache restart should not be required for an .htaccess change so I am definitely wrong http://stackoverflow.com/questions/142559/do-you-have-to-restart-apache-to-make-re-write-rules-in-the-htaccess-take-effec – buley Feb 06 '13 at 16:09