Mar 23

It occur to me how to add somekind like .htaccess user login authentication on nginx, it was called NginxHttpAuthBasicModule. You need to go to your nginx.conf.  Here is some example :

# vim /etc/nginx/nginx.conf

root /usr/local/www/page;
index  index.php;
location  /user  {
auth_basic            “Restricted”;
auth_basic_user_file  /usr/local/www/user.pass
}

location ~ \.php$ {
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME /usr/local/www/page$fastcgi_script_name;
include        fastcgi_params;
}

then create user.pass using htpasswd

# /usr/bin/htpasswd -c /usr/local/www/user.pass admin

New password:
Re-Type new password:
Adding password for user admin

then restart your nginx

# /etc/init.d/nginx stop

#/etc/init.d/nginx start

And now you can access the page http://localhost/user

Mar 20

In order to enable the mod_rewrite module in the Ubuntu server issue the following command:

# a2enmod rewrite

The above Apache2 Enable Module command will add the correct line in the /etc/apache2/apache2.conf file. The precise command will be added on /etc/apache2/mods-enabled/rewrite.load

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

then restart your apache2

#/etc/init.d/apache2 restart

then checked your apache modules on your phpinfo, create phpinfo.php on your web root directory

<? phpinfo(); ?>

then browse it

New Picture

Simple test:

Nice looking URLs (no querying) with pagination:
Suppose your url is: domain.com/article.php?name=title&page=5
You want to change: domain.com/articles/title/5/
Then write in .htaccess file:
RewriteRule ^articles/(A-Za-z0-9-]+)/([0-9]+)/?$ article.php?name=$1&page=$2 [L]

The rule is defined in regular expression. Here [L] means Last Rule. It’s called RewriteRule Flags.