Tag: redirect

301 Permanent Redirect NON WWW to WWW and viceversa on Nginx

This is my favorite and I think the more simple  if you want permanent redirect  from NON WWW to WWW insert the following code in the nginx configuration file nginx.conf :

server {
  listen 80;
  server_name www.debian-tutorials.com;
  rewrite ^/(.*)$ http://debian-tutorials.com/$1 permanent;
}
Permanent redirect from WWW to NON WWW in nginx, use this code in your nginx.conf :
server {
  listen 80;
  server_name debian-tutorials.com;
  rewrite ^/(.*)$ http://www.debian-tutorials.com/$1 permanent;
}

Enjoy!


301 Permanent Redirect NON WWW to WWW and viceversa on Apache2

Apache2 is one of the most widely used HTTP server has a lot of features and can be customized in many ways.

In fact, to this web server, there are basically two ways you can do this, using .htaccess directives or using a file httpd.conf. .

Some people prefer to use. htaccess files, since they reside in the website and can be modified by the site owner, which is not the case for the daemon configuration file:

 

Permanent redirect  NON WWW to WWW using apache2 server configuration:
ServerName debian-tutorials.com
RedirectMatch permanent ^/(.*) http://www.debian-tutorials.com/$1
DocumentRoot /path/to/your/site/files/
ServerName www.debian-tutorials.com

Redirect from HTTP to HTTPS with Apache Rewrite Rules

Just put this in your ..htaccess file.

// .htaccess HTTP to HTTPS Rewrite Rule
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


How to 301 Redirect Non-WWW to WWW URLs

The simplest way of achieving this is by altering the .htaccess file in your websites root directory.

Download the .htaccess file to your computer using your favorite FTP client, open and edit it.

If you do not have a .htaccess file you can create one and upload it, look harder tough, these files are usually hidden.

If your website root directory does have a .htaccess file open it and first check to see if the rewrite engine declaration is posted: RewriteEngine On

If the Rewrite Engine is On then go ahead and add this following code to your .htaccess file:

Remember to backup your .htaccess file before you start editing it.


Social Media

  
FeedBurner Subscribe



Categories

Page 1 of 11
Copyright © 2012 Linux Debian Tutorials | Debian Squeeze Tutorials. All rights reserved.
↑ Back to Top