more_rewrite在不同的机器上做的不一样

时间:2019-01-25 10:34:00

标签: apache mod-rewrite

我有两台机器(DEV / PROD),具有两个不同的apache版本,但配置相同。

DEV:Apache / 2.4.18 产品:Apache / 2.4.33

这是我的虚拟主机配置:

<VirtualHost *:14000>
  ServerName xxxx.com

  ErrorLog  /var/log/apache2/www.xxxx.com_error.log
  CustomLog /var/log/apache2/www.xxxx.com_access.log vhost_combined env=!nolog

  SetEnv ENVIRONMENT "PROD"
  SetEnv SITE "XXXX"
  SetEnv SITE_ID "7"

  ErrorDocument 404 /404.html

  <IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule "^/es/XXXX/(.*)$"  "/$1" [N]

    RewriteCond "%{DOCUMENT_ROOT}/sitecode/XXXX/static%{REQUEST_FILENAME}" -f
    RewriteRule "^(.+)" "%{DOCUMENT_ROOT}/sitecode/XXXX/static$1"  [L]

    RewriteCond "%{DOCUMENT_ROOT}/sitecode/XXXX/dynamic%{REQUEST_FILENAME}" -f
    RewriteRule "^(.+)" "%{DOCUMENT_ROOT}/sitecode/XXXX/dynamic$1"  [L]

    RewriteCond %{REQUEST_FILENAME} !\.(js|txt|html|gif|png|jpe?g|pdf|zip|css|ico|svg)$
    RewriteRule . /index.php [L]
  </IfModule>

  DocumentRoot /var/www/vhosts/site
  <Directory /var/www/vhosts/site>
    AllowOverride All
  </Directory>
</VirtualHost>

在DEV上一切正常,但在PROD上效果不佳。

样品申请

% curl https://xxxx.com/es/BASE/js/common.js
DEV上的

正常运行,mod_rewrite从路径中删除“ / es / BASE ”,并在右侧目录“ / var / www / vhosts / site”中查找静态文件/sitecode/XXXX/static/js/common.js

,但是在PROD中,相同的规则尝试在“ /var/www/vhosts/site/sitecode/XXXX/static/es/BASE/js/common.js ”中找到文件 请注意,未删除“ / es / BASE ”。

这是来自DEV的日志

[rid#7f30501030a0/initial] init rewrite engine with requested uri /es/BASE/js/common.js
[rid#7f30501030a0/initial] applying pattern '^/es/BASE/(.*)$' to uri '/es/BASE/js/common.js'
[rid#7f30501030a0/initial] rewrite '/es/BASE/js/common.js' -> '/js/common.js'
[rid#7f30501030a0/initial] applying pattern '^/es/BASE/(.*)$' to uri '/js/common.js'
[rid#7f30501030a0/initial] applying pattern '^(.+)' to uri '/js/common.js'
[rid#7f30501030a0/initial] rewrite '/js/common.js' -> '/var/www/vhosts/site/sitecode/XXXX/static/js/common.js'
[rid#7f30501030a0/initial] local path result: /var/www/vhosts/site/sitecode/XXXX/static/js/common.js
[rid#7f30501030a0/initial] go-ahead with /var/www/vhosts/site/sitecode/XXXX/static/js/common.js [OK]

这是来自PROD的日志

[rid#559c3a1c18f0/initial] init rewrite engine with requested uri /es/BASE/js/common.js
[rid#559c3a1c18f0/initial] applying pattern '^/es/BASE/(.*)$' to uri '/es/BASE/js/common.js'
[rid#559c3a1c18f0/initial] rewrite '/es/BASE/js/common.js' -> '/js/common.js'
[rid#559c3a1c18f0/initial] applying pattern '^/es/BASE/(.*)$' to uri '/js/common.js'
[rid#559c3a1c18f0/initial] applying pattern '^' to uri '/js/common.js'
[rid#559c3a1c18f0/initial] RewriteCond: input='https' pattern='!https' [NC] => not-matched
[rid#559c3a1c18f0/initial] applying pattern '^(.+)' to uri '/js/common.js'
[rid#559c3a1c18f0/initial] RewriteCond: input='/var/www/vhosts/site/sitecode/XXXX/static/es/BASE/js/common.js' pattern='-f' => not-matched
[rid#559c3a1c18f0/initial] applying pattern '^(.+)' to uri '/js/common.js'
[rid#559c3a1c18f0/initial] RewriteCond: input='/var/www/vhosts/site/sitecode/XXXX/dynamic/es/BASE/js/common.js' pattern='-f' => not-matched
[rid#559c3a1c18f0/initial] applying pattern '.' to uri '/js/common.js'
[rid#559c3a1c18f0/initial] RewriteCond: input='/js/common.js' pattern='!\\.(js|txt|html|gif|png|jpe?g|pdf|zip|css|ico|svg)$' => not-matched
[rid#559c3a1c18f0/initial] local path result: /js/common.js
[rid#559c3a1c18f0/initial] prefixed with document_root to /var/www/vhosts/site/js/common.js
[rid#559c3a1c18f0/initial] go-ahead with /var/www/vhosts/site/js/common.js [OK]

有什么问题吗?

xabi

0 个答案:

没有答案