发表于 2018-11-16 09:50:14

Nginx对于Discuz/joomla/drupal应用的正则写法

  1、 discuz rewrite
  rewrite ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2 last;
  rewrite ^(.*)/forum-(+)-(+)\.html$ $1/forumdisplay.php?fid=$2&page=$3 last;
  rewrite
  ^(.*)/thread-(+)-(+)-(+)\.html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=
  $3 last;
  rewrite ^(.*)/profile-(username|uid)-(.+)\.html$ $1/viewpro.php?$2=$3 last;
  rewrite ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3 last;
  rewrite ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2 last;
  2、 joomla rewrite
  location / {
  expires 30d;
  error_page 404 = @joomla;
  log_not_found off;
  }
  location @joomla {
  rewrite ^(.*)$ /index.php?q=$1 last;
  }
  C、 drupal rewirte
  if (!-f $request_filename) {
  rewrite ^(.*)$ /index.php?q=$1 last;
  break;
  }
  if (!-d $request_filename) {
  rewrite ^(.*)$ /index.php?q=$1 last;
  break;
  }
  3、Wordpress/ typecho
  A、wordpress rewrite
  if (-f $request_filename/index.html){
  rewrite (.*) $1/index.html break;
  }
  if (-f $request_filename/index.php){
  rewrite (.*) $1/index.php;
  }
  if (!-f $request_filename){
  rewrite (.*) /index.php;
  }
  B、typecho rewrite
  location / {
  index index.html index.php;
  if (-f $request_filename/index.html){
  rewrite (.*) $1/index.html break;
  }
  if (-f $request_filename/index.php){
  rewrite (.*) $1/index.php;
  }
  if (!-f $request_filename){
  rewrite (.*) /index.php;
  }
  }

页: [1]
查看完整版本: Nginx对于Discuz/joomla/drupal应用的正则写法