Your Ad Here
Showing posts with label .htaccess. Show all posts
Showing posts with label .htaccess. Show all posts

Thursday, November 6, 2014

How To Put Site Into Maintenance Mode

Using .Htaccess

If you are using the Apache server, you can use.htaccess to control access of the directories within the server, and send a response code of the server status.
To put the website into maintenance mode, you can use the 503 status code, which indicates that the server is temporarily unavailable.
Before we specify anything in .htaccess, however, we need to create a new file in.html or .php format, and add a message in the file, e.g.
Sorry we are down for maintenance, but we’ll be back up shortly.
Style your page. Next, open the .htaccess file in your server, and add the following:
  1. <IfModule mod_rewrite.c>  
  2. RewriteEngine on  
  3. RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000  
  4. RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]  
  5. RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]  
  6. RewriteRule .* /maintenance.html [R=503,L]  
  7. </IfModule>  

This will set the server status code to 503, while also redirects visitors to the maintenance page. You can set your IP address with the following line RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.000 so that you will still be able to access your website.

Friday, January 24, 2014

How to redirect old domain to new domain or some location to new location

Implementing the www redirect

First, make sure that mod_rewrite is enabled.  Just make sure that this line appears somewhere in your .htaccess file above the rule that we are about to add:

RewriteEngine On

To redirect from non-www to the www version of your site,
 use the following rule:

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule (.*)$ http://www.example.com/$1 [R=301,L]

To redirect from www to the non-www version of your site, use the following rule:

RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule (.*)$ http://example.com/$1 [R=301,L]

Make sure that you replace ‘example.com’ with your actual domain!

To redirect from old domain to the new-domain of your site, use the following rule:


RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]


If you want to redirect from some location to subdomain you can use:

Redirect 301 /Old-Location/ http://subdomain.yourdomain.com