.htaccess WAMP mod_重写规则不起作用
我正在尝试在本地wamp服务器上使用。ai缓存文件夹没有显示,图像根本没有被替换。根据我尝试的重写规则:?:jpe?g | gif | png$test.jpg在.htaccess文件中,并在同一文件夹中添加test.jpg,但这不会改变任何东西 在wamp菜单中,选中Apache->Apache Modules->rewrite_module,并在httpd.conf LoadModule rewrite_Modules/mod_rewrite.so中取消注释该模块 每当我更改.htaccess时,我都会重新启动wamp中的所有服务。另外,如果我在顶部写asdf,它会给出一个500内部服务器错误,因此我知道文件正在读取 我做错了什么 下面是位于两个子目录www/demos/test/中的.htaccess文件:.htaccess WAMP mod_重写规则不起作用,.htaccess,mod-rewrite,wamp,wampserver,file-extension,.htaccess,Mod Rewrite,Wamp,Wampserver,File Extension,我正在尝试在本地wamp服务器上使用。ai缓存文件夹没有显示,图像根本没有被替换。根据我尝试的重写规则:?:jpe?g | gif | png$test.jpg在.htaccess文件中,并在同一文件夹中添加test.jpg,但这不会改变任何东西 在wamp菜单中,选中Apache->Apache Modules->rewrite_module,并在httpd.conf LoadModule rewrite_Modules/mod_rewrite.so中取消注释该模块 每当我更改.htacces
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Adaptive-Images -----------------------------------------------------------------------------------
# Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:
# RewriteCond %{REQUEST_URI} !ignore-this-directory
# RewriteCond %{REQUEST_URI} !and-ignore-this-directory-too
RewriteCond %{REQUEST_URI} !assets
# don't apply the AI behaviour to images inside AI's cache folder:
RewriteCond %{REQUEST_URI} !ai-cache
# Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
# to adaptive-images.php so we can select appropriately sized versions
RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php
# END Adaptive-Images -------------------------------------------------------------------------------
</IfModule>
这是我的httpd.conf部分:
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "c:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options None
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1:
</Directory>
好吧,我知道为什么它不起作用了!这根本不是WAMP/localhost问题 由于某些原因,adaptive images附带的默认.htacess文件并非适用于所有情况。但是我只需要在重写规则的末尾添加[NC,L]。html和image标记的扩展名为.jpg,小写,但我的图像文件是用caps.jpg编写的,在打开文件浏览器中的文件扩展名之前,我没有注意到这一点 nocase | NC:使模式比较不区分大小写。 最后| L:立即停止重写过程,不要应用任何 更多规则。特别要注意每个目录和.htaccess的注意事项 上下文另请参见结束标志。 以下是最终代码:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Adaptive-Images -----------------------------------------------------------------------------------
# Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:
# RewriteCond %{REQUEST_URI} !ignore-this-directory
# RewriteCond %{REQUEST_URI} !and-ignore-this-directory-too
RewriteCond %{REQUEST_URI} !assets
# don't apply the AI behaviour to images inside AI's cache folder:
RewriteCond %{REQUEST_URI} !ai-cache
# Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
# to adaptive-images.php so we can select appropriately sized versions
RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php [NC,L]
# END Adaptive-Images -------------------------------------------------------------------------------
</IfModule>
类似的问题也解决了。