httpd.conf中的设置对于.htaccess
是正确的以下是.htaccess的内容:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^Minecraft(Skin|Cloak)s/
RewriteRule ^Minecraft(Skins|Cloaks)/([a-zA-Z_0-9]+)(?:.*) /$1/$2.png
我希望得到这个结果:
输入:/ MinecraftSkins / u5er_n4me-skin-317982479812
输出:/Skins/u5er_n4me.png
输入:/ MinecraftCloaks / u5er_n4me-cape-317982479812
输出:/Cloaks/u5er_n4me.png
但没有发生任何事情,只有404返回,没有重写工作。
我的Regexp错了吗?
日志: [Mon Sep 08 17:39:30.089346 2014] [rewrite:trace2] [pid 5212:tid 1108] mod_rewrite.c(468):[client 192.168.1.1:57989] 192.168.1.1 - - [skins.jsw3286.info/ sid#27866e0] [摆脱#27dc240 / initial] init重写引擎请求uri / MinecraftSkins / jsw-18947
[Mon Sep 08 17:39:30.089346 2014] [rewrite:trace1] [pid 5212:tid 1108] mod_rewrite.c(468):[client 192.168.1.1:57989] 192.168.1.1 - - [skins.jsw3286 .info / sid#27866e0] [摆脱#27dc240 / initial]通过/ MinecraftSkins / jsw-18947
[Mon Sep 08 17:39:30.090346 2014] [rewrite:trace3] [pid 5212:tid 1108] mod_rewrite.c(468):[client 192.168.1.1:57989] 192.168.1.1 - - [skins.jsw3286 .info / sid#27866e0] [rid#27dc240 / initial] [perdir F:/ mcsrv / SkinStation / root /] strip per-dir prefix:F:/ mcsrv / SkinStation / root / MinecraftSkins / jsw-18947 - > MinecraftSkins / JSW-18947
[Mon Sep 08 17:39:30.090346 2014] [rewrite:trace3] [pid 5212:tid 1108] mod_rewrite.c(468):[client 192.168.1.1:57989] 192.168.1.1 - - [skins.jsw3286 .info / sid#27866e0] [摆脱#27dc240 / initial] [perdir F:/ mcsrv / SkinStation / root /]应用模式'^ Minecraft(Skins | Cloaks)/([a-zA-Z_0-9] +)( ?:。*)'到'uri'MinecraftSkins / jsw-18947'
[Mon Sep 08 17:39:30.090346 2014] [rewrite:trace1] [pid 5212:tid 1108] mod_rewrite.c(468):[client 192.168.1.1:57989] 192.168.1.1 - - [skins.jsw3286 .info / sid#27866e0] [摆脱#27dc240 / initial] [perdir F:/ mcsrv / SkinStation / root /]通过F:/ mcsrv / SkinStation / root / MinecraftSkins / jsw-18947
然后呈现404。
答案 0 :(得分:1)
您的RewriteCond
未通过,因为REQUEST_URI
以前导斜杠(/
)开头。
此外,您的RewriteCond
在您的情况下无用,因此您可以将其删除。
请改用此代码
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/$1/$2\.png !-f
RewriteRule ^Minecraft(Skins|Cloaks)/([a-zA-Z_0-9]+) http://skins.minecraft.net/Minecraf$1/$2.png [R=301,L]
RewriteRule ^Minecraft(Skins|Cloaks)/([a-zA-Z_0-9]+) $1/$2.png [L]