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/");
?>
Related
We are rebuilding a website for a client from ASP to WordPress. This website will have a different domain, url structure, and file extension. I am only just getting my head around htaccess 301 redirects, and I know enough that I can't do the following:
Redirect 301 http://www.site1.com/about_us.asp https://site2.com/about/
Redirect 301 http://www.site1.com/art-specs/ https://site2.com/specs/
Redirect 301 http://www.site1.com/page/product1/ https://site2.com/product1/
There are about 12 links in total that need to be redirected, and I want to make sure that it is done right the first time as a client's SEO rankings are on the line.
Is there a variation of the above format that I could use? Or a rewrite rule that needs to be done first? Any help (and explanations) would be greatly appreciated!
After looking more into it, I realised that the htaccess file shouldn't need anything other than relative access to the original domain.
i.e. You shouldn't need to declare: http://www.site1.com/about_us.asp since the server and domain should be configured in such a way that /about_us.asp means the same thing.
So the correct answer would be to:
[1] Configure the server (in my case cPanel) by having the original domain added as an addon domain (e.g http://www.site1.com/).
[2] In the htaccess file I would add each of the 301 redirects to the htaccess file:
Redirect 301 /about_us.asp https://site2.com/about/
Redirect 301 /art-specs/ https://site2.com/specs/
Redirect 301 /page/product1/ https://site2.com/product1/
...for each redirect
[3] And finally, adding the following to the bottom of the htaccess file will catch everything else and redirect them to the home page:
RedirectMatch 301 .* https://site2.com
In my Apache server I need to redirect my URL http://10.11.10.11:9003/ObiController to http://abc.co.in.
How do I redirect to accomplish this ?
For redirecting in apache with port, you can add the below line to you httpd.conf file
Redirect 301 /ObiController http://abc.co.in:9003
A 301 redirect refers to the HTTP status code that is returned when a HTTP request for a specific resourse is redirected.
Easier method is to add the following line in your .htaccess file located under your document root folder. This uses regular expression and checks for "ObiController" word only.
RedirectMatch 301 ^ObiController$ http://abc.co.in
I'm trying to redirect using .htaccess from a subfolder to another domain using the following code:
Redirect 301 / https://newsite.com
Subfolder name is oldfolder
When I click http://website.com/oldfoler, I'm redirectd to https://newsite.com/oldfolder. When I click on http://website.com/oldfoler/about-us, I'm redirected to https://newsite.com/oldfolder/about-us
My .htaccess file is located in oldfolder
What am I doing wrong?
That is because that is the default behavior of Redirect.
Then any request beginning with URL-Path will return a redirect
request to the client at the location of the target URL. Additional
path information beyond the matched URL-Path will be appended to the
target URL.
https://httpd.apache.org/docs/current/mod/mod_alias.html#redirect
You need to use RedirectMatch or RewriteRule.
So if you want to redirect /oldfolder to new domain you can do this.
RedirectMatch 301 ^/oldfolder/? http://newsite.com/
I want to redirect 301 old url to new url.
my old url is;
http://www.domainname.com/special
and new url is;
http://www.domainname.com/offers
I tried this code:
redirect 301 /http://www.domainname.com/special http://www.domainname.com/offers
But still now it's not redirecting & taking me to the old URL which does'nt exist.
Try this :
Redirect 301 /special /offers
Second argument of Redirect Directive is the URL Path, it doesn't start with Scheme and hostname.
There are various ways to do this and various redirects, I've listed them below:
301 (Permanent) Redirect: Point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the "example.com" domain:
This allows you to redirect your entire website to any other domain
Redirect 301 / http://example.com/
302 (Temporary) Redirect: Point an entire site to a different temporary URL. This is useful for SEO purposes when you have a temporary landing page and plan to switch back to your main landing page at a later date:
This allows you to redirect your entire website to any other domain
Redirect 302 / http://example.com/
Redirect index.html to a specific subfolder:
This allows you to redirect index.html to a specific subfolder
Redirect /index.html http://example.com/newdirectory/
Redirect an old file to a new file path:
Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html
Redirect to a specific index page:
Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html
I want to redirect the user from the default page index.php to another page.
i.e: http://www.example.com/project/ to http://www.example.com/project/main/ar/
I tried this Redirect / /main/ar/, but insted it redirects to http://www.example.com/main/ar/project/
What is the wrong?
Maybe try
Redirect /project/ /project/main/ar/
Depending of if you need to redirect all children paths of project you may want to look at this thread -> .htaccess 301 redirect path and all child-paths