从另外一台服务器上迁移过来的,那台服务器是liunx+apache,迁移后是linux+nginx
问题:.htaccess问题,apache环境登陆网址后台正常,nginx将.htaccess的伪静态通过官方转换工具转换时提示报错
nginx: [emerg] unknown "0" variable
nginx: configuration file /www/server/nginx/conf/nginx.conf test failed
.htaccess伪静态规则
- # Turn on URL rewriting
- RewriteEngine On
- # Installation directory
- RewriteBase /
- #mobile start
- RewriteCond %{HTTP_HOST} ^m.xxx.com$
- RewriteCond %{REQUEST_URI} !^/uploads/
- RewriteRule (.*) /phone/$1 [L]
- #mobile end
- RewriteRule ^(uploads/.*?_\d+x\d+\.(jpg|gif|png|jpeg))$ /image/index.php?$1 [L,NC]
- # Protect hidden files from being viewed
- <Files .*>
- Order Deny,Allow
- Deny From All
- </Files>
- # Protect application and system files from being viewed
- RewriteRule ^(?:v5|modules|system)\b.* index.php/$0 [L]
- # Allow any files or directories that exist to be displayed directly
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_URI} !^/(uploads|public|newtravel|phone|payment|plugins)(/)?
- #RewriteCond %{REQUEST_FILENAME} !-d
- # Rewrite all other URLs to index.php/URL
- RewriteRule .* index.php/$0 [PT]
复制代码
转换后的nginx伪静态规则
- if ($http_host ~ "^m.xxx.com$"){
- set $rule_0 1$rule_0;
- }
- if ($uri !~ "^/uploads/"){
- set $rule_0 2$rule_0;
- }
- if ($rule_0 = "21"){
- rewrite /(.*) /phone/$1 last;
- }
- rewrite ^/(uploads/.*?_\d+x\d+\.(jpg|gif|png|jpeg))$ /image/index.php?$1 last;
- rewrite ^/(?:v5|modules|system)\b.* /index.php/$0 last;
- if (!-f $request_filename){
- set $rule_3 1$rule_3;
- }
- if ($uri !~ "^/(uploads|public|newtravel|phone|payment|plugins)(/)?"){
- set $rule_3 2$rule_3;
- }
- if ($rule_3 = "21"){
- rewrite /.* /index.php/$0;
- }
复制代码
我是菜鸟,求各路大神指点下呢,谢谢!
|
|