Enable OSWallpaper SEO URLs on Nginx
May 29, 2009 by Mark
Filed under Open Source Software
First enable the clean url by editing config.php (inside includes folder).
//enable mod rewrite urls. 0=disabled, 1=enabled for SEO Friendly URLS $Gbl["ManualModRewrite"] = 1;
The original rewrite rule (Apache) for the script are as follows :
RewriteEngine On #PAGES RewriteRule ^([^/]*)/$ index.php?p=$1 [L] # CATEGORY RewriteRule ^([^/]*)/([^/]*)/$ index.php?p=$1&i=$2 [L] # CATEGORY PAGES RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ index.php?p=$1&i=$2&pg=$3 [L]
You have to add your custom rewrite rule to nginx base on the Apache rewrite rule above. But don’t worry because I already do that for you. All you have to do is open your nginx.conf file or your virtual host configuration and add the following rule to the section location /.
if (!-e $request_filename){
rewrite ^/([^/]*)/$ /index.php?p=$1 last;
rewrite ^/([^/]*)/([^/]*)/$ /index.php?p=$1&i=$2 last;
rewrite ^/([^/]*)/([^/]*)/([^/]*)/$ /index.php?p=$1&i=$2&pg=$3 last;
}
Once added, save the configuration file and close your text editor. Now restart nginx with the following command.
/etc/init.d/nginx restart
Congratulation you have clean url on your OSWallpaper script now.



