301 redirect works in Firefox but not Safari or Chrome? - http-status-code-301

I have this simple redirect at the top of my htaccess to redirect a Wordpress category archive to a new page. It works on firefox but not other browsers. If I eliminate the category I get a 404 error.
Redirect 301 /category/forums-and-events/ /forums-and-events/
I've emptied the browsers' cache. What can I do to get it to work?

In Wordpress this works for redirecting to an absolute url and avoids htaccess:
<?php
wp_redirect( $location, $status );
exit;
?>
$location is the url to direct to, $status is either 301 (permanent redirect) or 302 (temporary)
http://codex.wordpress.org/Function_Reference/wp_redirect

Related

Redirect full URL to another full URL?

I want to 301 redirect from https://whatever-12345.de/something.html to https://whatever.de/something.html using a .htaccess file. I could not find a working example and this does not work:
redirect 301 https://whatever-12345.de/something.html https://whatever.de/something.html
Ideas?
First alternative, redirect a specific page called /sourcepage.html to another URL:
Redirect 301 /sourcepage.html http://Exampledomain.com/
Second alternative, redirect the whole domain to another URL:
Redirect 301 / http://www.Exampledomain.com/
And last, redirect one file to another file, locally, in the same domain:
Redirect 301 /old/path/oldpage.html http://www.currentdomain.com/new/path/newpage.html
PHP:
Now, by this method, you need FTP access to edit files in your server as well. We will create a PHP file named old.php. Here’s how this file will look like:
<?php
header("Location: http://www.mynewwebsite.com/blog/");
?>
This way, whenever we access this specific PHP file, the user will be redirected to our destination site.
We can also use a more complete PHP file, specifying that this is a 301 redirect (permanent). In this case, the PHP file would look like:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mynewwebsite.com/blog/");
?>

301 redirect in htaccess doesn't work. What am I doing wrong?

I've made an htaccess file, but several testers tell me it's not right.
Domain B is going offline and I want to redirect all the pages to new pages on domain A.
This is the code:
redirect 301 / https://domain-A.com/
redirect 301 /page-1/domain-B/ https://domain-A.com/page-1/
redirect 301 /page-2/domain-B/ https://domain-A.com/page-2/
redirect 301 / https://domain-A.com/
redirect 301 /page-1/domain-B/ https://domain-A.com/page-1/
redirect 301 /page-2/domain-B/ https://domain-A.com/page-2/
Your rules are in the wrong order. The Redirect directive is prefix-matching. The first rule redirects everything (and preserves the URL-path). The second and third rules are never processed. (What exactly is the "tester" reporting? Is this a thrid party tool or a real "tester" person?)
If you request /page-1/domain-B/ you will see that you are not redirected as intended. (You are redirected to https://domain-A.com/page-1/domain-B/, not https://domain-A.com/page-1/ as would seem to be the intention.)
You need to reverse the order of these rules. The most specific needs to be first.
For example:
Redirect 301 /page-1/domain-B/ https://domain-A.com/page-1/
Redirect 301 /page-2/domain-B/ https://domain-A.com/page-2/
Redirect 301 / https://domain-A.com/
You will need to clear your browser cache before testing since the erroneous 301s will have been cached by the browser. Test first with 302 redirects to avoid caching issues.
/page-1/domain-B/
And /domain-B/ is actually in the URL-path?

301 redirects clashing possibly with CloudFlare

My old 301 redirects in .htaccess are no longer working because something is redirecting things twice. Example of redirect:
Redirect 301 /oldpage.html //www.example.com/newpage.php
This used to work, but now it goes to:
https://www.example.com//www.example.com/newpage.php
In CloudFlare, I have a Page Rule for the www redirection:
https://example.com/*
Forwarding URL (Status Code: 301 - Permanent Redirect, Url: https://www.example.com/$1)
And my "Always Use HTTPS" in CloudFlare is on. What could be causing the double redirect?
I put one of the URLs into a redirect checker http://www.redirect-checker.org/
and noticed that for some reason the URLs go back to http, then back to https again. So I went back and edited my .htaccess file to explicitly include the https:
Redirect 301 /oldpage.html https://www.example.com/newpage.php
And now the redirect works as expected, at least in the incognito window. The regular browser isn't yet reflecting the change.

.htaccess Redirect 301 Issue

I am having an htaccess issue that I cannot seem to figure out.
On my site I have several pages that have /wiget/ in the url.
.com/wiget/
.com/wigeta/
.com/wigeb/
.com/wigetc/
.com/shop/wigeta/
.com/shop/wigetb/
In my htaccess file I am using the following:
Redirect 301 /wiget/ http://www.site.com/content/wiget/
Redirect 301 /wigeta/ http://www.site.com/content/wigeta/
Redirect 301 /wigetb/ http://www.site.com/content/wigetb/
Etc.
What is happening, is that every URL with /wiget/ /wigeta/ /wigetb/ in it is getting redirected incorrectly. For example, these urls:
.com/shop/wiget/ is being sent to .com/shop/content/wiget/
.com/shop/wigeta/ is being sent to .com/shop/content/wigeta/
.com/shop/wigetb/ is being sent to .com/shop/content/wigetb/
What I want is only pages that have .com/wiget/ or .com/wigeta/ or .com/wigetb/ to be redirected to their .com/content/wiget{x}/ page
I am a rookie at htaccess and I cannot drum up the solution.
So basically you want to specify that your url have to start with /wiget/
RewriteRule ^/wiget/ /content/wiget/ [L,R=301]

htaccess or php 301 redirect url

I do not know a lot htaccess and redirect url (301) with php as;
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://www.exampledomain.com" );
Is there any difference or advantage between the two for google?Can I must use htaccess for redirect url?
You have to use both these headers to redirect something permanently. Both headers are needed. I echo this same header for my old blog url. And I get all the referrals, visitors, inlinks from google to the new domain.
It does not matter how you echo the headers. It matters those headers exist.
I know PHP well so I have used a PHP file that echos only these headers
HTTP/1.1 301 Moved Permanently
Location: http://shiplu.mokadd.im/
If you use 302 redirect Google will remember your current url and associate all your links to that old url.

Resources