阿帕奇:; file.123.ext&QUOT无法从&QUOT重新路由的URL;到" file.ext"在htaccess文件使用mod_rewrite [英] Apache: Can't reroute URL from "file.123.ext" to "file.ext" using mod_rewrite in htaccess file

查看:72
本文介绍了阿帕奇:; file.123.ext&QUOT无法从&QUOT重新路由的URL;到" file.ext"在htaccess文件使用mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现清除缓存,为prescribed方式: http://html5boilerplate.com /文档/ cachebusting /

然而,当我添加以下到我的媒体文件夹中的.htaccess文件:

 < IfModule mod_rewrite.c>
    的RewriteCond%{} REQUEST_FILENAME!-f
    的RewriteCond%{} REQUEST_FILENAME!-d
    重写规则^ \(\ d +)\(JS | CSS | PNG | JPG | GIF)(+)。$ $ 1. $ 3 [L]
< / IfModule>
 

,然后我试图访问一个样式表的:/media/css/styles.1234.css阿帕奇抱怨有:

 未找到

所请求的URL /media/css/styles.1234.css在此服务器上找到。
 

我可以在/media/css/styles.css访问styles.css的所以它的存在和它的作品。我也知道,htaccess的文件被处理,因为我们也禁止目录被浏览与选项-Indexes的媒体文件夹。下面是全部的htaccess文件:

 选项-Indexes
设置AllowOverride所有

< IfModule mod_rewrite.c>
    的RewriteCond%{} REQUEST_FILENAME!-f
    的RewriteCond%{} REQUEST_FILENAME!-d
    重写规则^ \(\ d +)\(JS | CSS | PNG | JPG | GIF)(+)。$ $ 1. $ 3 [L]
< / IfModule>
 

此外mod_rewrite的已被证实要加载使用此命令:a2enmod重写。不知道我在做什么错了?

解决方案

下面是解决我的问题......即使加载mod_rewrite的,它需要在设定为

。所以,我只是交锋RewriteEngine叙述上......造成htaccess文件:

 选项-Indexes

< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^ \(\ d +)\(JS | CSS | PNG | JPG | GIF)(+)。$ $ 1. $ 3 [L]
< / IfModule>
 

I'm trying to implement cache busting, as prescribed by: http://html5boilerplate.com/docs/cachebusting/

However when I add the following to the .htaccess file in my media folder:

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
</IfModule>

and then I try to access a style sheet at: "/media/css/styles.1234.css", Apache complains with:

Not Found

The requested URL /media/css/styles.1234.css was not found on this server.

I can access styles.css at "/media/css/styles.css" so it's there and it works. I also know that the htaccess file gets processed because we also disallow directories from being browsed in the media folder with "Options -Indexes". Here is the htaccess file in its entirety:

Options -Indexes
AllowOverride All

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
</IfModule>

Also mod_rewrite has been confirmed to be loaded with this command: 'a2enmod rewrite'. Not sure what I'm doing wrong...

解决方案

Here is the solution to my problem... Even though mod_rewrite was loaded, it needed to be set to on. So I just aded "RewriteEngine On"... resulting htaccess file:

Options -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
</IfModule>

这篇关于阿帕奇:; file.123.ext&QUOT无法从&QUOT重新路由的URL;到&QUOT; file.ext&QUOT;在htaccess文件使用mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆