If you run an Apache2  server then you have no doubt seen the following error messages a thousand times in your error.log file:

File does not exist: /var/www/robots.txt

File does not exist: /var/www/favicon.ico

As you know by now  not having a favicon.ico file  web browsers will requesting  it each time. But you can tell Apache2  not to log the event as a mistake message.

You will still see the request in the access.log, but at least you will have a cleaner error.log file.

Solution:

Continue Reading…

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!

For the sake of SEO is better to have one URL for each post or article on your site, like having two uris respond with the same content can lead to duplicate content and is penalized by search engines, especially Google, which is the largest by far.

Therefore, if you’re using Nginx and want to remove the trailing slash at the end of every URI in your site.

So if someone writes:

http://yoursite.com/ will be automatically redirected to http://yoursite.com

Here is the code needed to put it in your nginx.conf.

rewrite ^/(.*)/$ /$1 permanent;

That goes in the server section so something like this:

server {
listen  :80;
server_name  www.yoursite.com;
rewrite ^/(.*)/$ /$1 permanent;
}

Nginx will handle the trailing slashes now.

Nginx Canonical Domain

Valic —  July 19, 2011 — Leave a comment
############# www to non-www
server{
  listen 80;
  server_name  www.debian-tutorials.com;
  rewrite ^(.*) http://debian-tutorials.com$1 permanent;
}

############# non-www to www
server {
  if ($host ~* ^([a-z0-9\-]+\.(com|net|org))$) {
    set $host_with_www www.$1;
    rewrite ^(.*)$ http://$host_with_www$1 permanent;
  }
}

Enjoy

The following tutorial is done with Debian Squeeze version 6.0.2.
In this tutorial, I will show you the shortest and easiest way to set up nginx  with PHP5, MySQL and phpmyadmin running through FastCGI:

Step 1: Installation:

apt-get install nginx mysql-server mysql-client php5 php5-cgi php5-mysql phpmyadmin

NOTE: After you have installed all above you will need to edit the php.ini file:
Open php.ini file end remove the ; in front of the line cgi.fix_pathinfo=1

Step 2: Make PHP FastCGI daemon listening on port 9000 on localhost and start at boot.

Edit the /etc/rc.local file and put the following content:

vim /etc/rc.local
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

Step 3: Create virtual host file for your site:

Continue Reading…

Page 2 of 3123