如何在 mod_rewrite htaccess 中进行 if ... else

问题描述 投票:0回答:0

我在配置 .htaccess 文件时遇到问题

<If "%{REMOTE_ADDR} == '127.0.0.1'"> RewriteRule ([^.]+\.(jpg|png))$ https://cdn.amante.co.kr/$1 [R=301,L,NC] </If>

错误: 找不到对象! 在此服务器上找不到请求的 URL。引用页面上的链接似乎有误或已过时。请将该错误告知该页面的作者。

如果您认为这是服务器错误,请联系网站管理员。

错误 404

`

RewriteEngine On
RewriteBase /
Options +FollowSymLinks -Indexes
  <If "%{REMOTE_ADDR} == '127.0.0.1'">
RewriteRule ([^.]+\.(jpg|png))$ https://cdn.amante.co.kr/$1 [R=301,L,NC]
</If>
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^asset.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REMOTE_ADDR} !^12.345\.678\.901$


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

`

.htaccess
© www.soinside.com 2019 - 2024. All rights reserved.