【问题标题】:Apache 1.3 Rewrite [closed]Apache 1.3重写[关闭]
【发布时间】:2016-07-05 20:55:51
【问题描述】:

我在 .htaccess 中有这个规则,它适用于 apache 2.4.X 但不适用于 apache 1.3,请告诉我如何使它适用于 apache 1.3.42

RewriteEngine On
RewriteBase /

#HTML
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)[B-Z]{3}(.*)\D{1}\.gif$
RewriteRule ^(.*)\.gif$ /AdDeveloper_SaDnOJ2.php?file=$1.html [NC,L]


#IMAGE
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)[B-Z]{3}(.*)\d{1}\.gif$
RewriteRule ^(.*)\.gif$ /AdDeveloper_SaDnOJ2.php?file=$1.gif [NC,L]

#JAVASCRIPT
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} SaDnOJ2\.js$
RewriteRule ^(.*)\.js$ /AdDeveloper_SaDnOJ2.php?file=script.js [NC,L]

【问题讨论】:

  • 不能简单地更新版本吗? Apache 1.3.42 可以追溯到 2010 年,那是信息技术领域的时代

标签: regex apache .htaccess mod-rewrite


【解决方案1】:

Apache 1. 使用 POSIX 扩展正则表达式,而那些不理解速记字符类,如 \d。所以试试这个:

RewriteEngine On
RewriteBase /

#HTML
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)[B-Z]{3}(.*)[^0-9]{1}\.gif$
RewriteRule ^(.*)\.gif$ /AdDeveloper_SaDnOJ2.php?file=$1.html [NC,L]


#IMAGE
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)[B-Z]{3}(.*)[0-9]{1}\.gif$
RewriteRule ^(.*)\.gif$ /AdDeveloper_SaDnOJ2.php?file=$1.gif [NC,L]

#JAVASCRIPT
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} SaDnOJ2\.js$
RewriteRule ^(.*)\.js$ /AdDeveloper_SaDnOJ2.php?file=script.js [NC,L]

【讨论】:

  • 谢谢,它正在工作!
  • 请删除这些无用的{1}
猜你喜欢
  • 2013-12-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-10
  • 1970-01-01
  • 1970-01-01
  • 2011-09-24
  • 2011-09-06
  • 2012-10-02
相关资源
最近更新 更多