Дек
09
2009
Правила nginx rewrite для популярных CMS.
Последнее время все чаще приходится переводить проекты клиентов на Nginx, соответственно клиенты разные, движки используют разные. Вот что удалось накопить, в основном нарыл по просторам интернет, но то что не удалось, написал сам. Привожу корневой location.
Wordpress:
location / { root /var/www/hilik.org.ua; index index.php index.html index.htm; if (!-e $request_filename) { rewrite (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ /index.php last; } }
CMS Made Simple:
location / { root /var/www/hilik.org.ua; index index.php index.html index.htm; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?page=$1 last; } }
Joomla 1.5
location / { root /var/www/hilik.org.ua; index index.php index.html index.htm; if (!-e $request_filename) { rewrite ^(.+)$ /index.php?q=$1 last; } }
И для Simple Mashine Forum с плугином Pretty Urls, тут реврайт стоит только на разделы и темы, остальное я не стал переводить на SEO URL:
location /forum/ { root /var/www/hilik.org.ua; index index.php; rewrite ^(/forum)/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?/?$ $1/index.php?pretty%3Bboard=$2.0 last; rewrite ^(/forum)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/[0-9]?/?$ $1/index.php?pretty%3Bboard=$2.$3 last; rewrite ^(/forum)/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?/?$ $1/index.php?pretty%3Bboard=$2%3Bt opic=$3.0 last; rewrite ^(/forum)/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/[0-9]?/?$ $1/index.ph p?pretty%3Bboard=$2%3Btopic=$3.$4 last; }
Для ModX:
location / { root /var/www/hilik.org.ua; index index.php index.html ; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?q=$1 last; } }
В общем, при должном желании, использовать nginx для замены Apache можно. При этом мы получаем прирост производительности.




By Dmitriy, 03.08.2010 @ 14:15
Привет, а в joomla при этом в урле остается /index.php/ – возможно его оттуда убрать или на что-то более красивое заменить?