How to redirect url (httpd) - linux

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

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/");
?>

Redirect entire site to other url with htaccess

I have a site which you can access with or without https rule. So, I need to make a redirect to another page. Example:
My website is: www.google.com so I can access by the moment as https://www.google.com and http://www.google.com but I need when you get into my website trough http or https way you must have to redirect to www.yahoo.com.
Besides I need the url redirection too to any subdomain or url which exists in http://www.google.com or https://www.google.com
How can I do this? I have no found alredy information about it in S.O. Thanks.
Very simple. You can use the following Redirect in your htaccess to redirect all requests from your site to the other domain
RedirectMatch 301 / http://yahoo.com/

redirect using .htaccess not working

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/

Redirect directory to a subdomain

I have my domain pointed to a Rails app in Heroku, so for example, when you wanted to access some video, you would have an URL such as:
http://codigofacilito.com/video/W53XHWkbz34
We need to change that app to a subdomain, so the updated version would be:
http://videos.codigofacilito.com/video/W53XHWkbz34
What I want to know is:
Is there a way to redirect people to the new url with the subdomain videos by using the .htaccess file.
If you need this rule to only be applied to the video route, then give the following a try:
In your document root's .htaccess file, insert the following rule:
RewriteRule ^(video/.*)$ http://videos.codigofacilito.com/$1 [R=301,L,NC]
This works for me
RedirectMatch 301 ^/xxx/(.*)$ http://xxx.domain.com/$1
Using mod_alias:
Redirect permanent /video http://videos.codigofacilito.com/video
The keyword permanent causes Apache to send an HTTP status of 301 Moved Permanently instead of 302 Found.

301 redirect to new URL from htaccess

Needs a favour from your side, I have added following rule in htaccess files not sure why it is not executing can you check and let us know if any issue
Redirect 301 /product/rose-elliot%E2%80%99s-__060727.aspx http://www.website.co.uk/ahhgh.html
Redirect 301 /abc/%20/index.php/customer/account/login/ https://www.website.co.uk/customer/account/login/
URI's get decoded before being sent through the URL-file-mapping processing pipeline. So you need to unescape the %'s:
Redirect 301 "/product/abcd.aspx" http://www.website.co.uk/abcd.html
Redirect 301 "/abcd/ /index.php/customer/account/login/" https://www.website.co.uk/customer/account/login/
You'll need to make sure you're using a text editor that supports unicode.

Resources