Articles of .htaccess

可以将Apacheconfiguration为忽略损坏的.htaccess文件,但如果它们是正确的,请尊重它们?

我有一个程序编写和更新.htaccess文件中的一些RewriteRules(主要configuration是在虚拟主机部分)。 这在大多数情况下工作正常,但有时文件被损坏。 发生这种情况时,服务器响应每个请求500内部服务器错误,因为.htaccess文件已损坏。 是否有失败保护选项,或者我可以configuration告诉Apache它应该忽略.htaccess文件,如果它是腐败的,但尊重它,如果它是好的? 或者至less是否有一个工具,我可以用来定期检查.htaccess文件是否有效(例如通过cron作业),并删除它是否损坏?

如何保护开放日记系统的原始提交文件

我已经在我自己的服务器上安装了ojs 。 在安装过程中,需要创build一个可由php(apache = www-data)写入的文件夹,但不能从浏览器访问。 该文件夹用于保存上传的稿件,这些稿件不得为公众所见,但必须由软件自己阅读。 我改变了httpd.conf文件来拒绝文件夹中的文件列表,但问题似乎并没有完全解决。 实际上,尽pipe文件名是随机的,但如果恶意或者好奇的用户具有原稿的确切文件名,则他/她可以下载文件。 请注意,现在在我的服务器(Ubuntu 12.04.4)中有很多这样的手稿。 有什么办法可以拒绝他们的下载(至less对于没有注册为编辑的未经授权的用户)?

使用Varnish + Apache将login用户redirect到https,匿名到http

我在Drupal前面的Apache前面有一个清漆服务器。 我想要做的是将我的login表单redirect到https(很简单),然后将所有已login(已authentication)的用户始终redirect到https,同时将匿名访问者始终redirect到http(出于性能原因) 。 我不希望经过身份validation的用户在点击http://mysite.com/some/page- >的绝对链接时拥有混合模式的体验,因此,如果协议不是通过https身份validation,那么总是会将已通过身份validation的用户redirect到https HTTPS。 是否有可能使用某种组合的Varnish + Apacheconfiguration来做这样的事情? 或者是唯一的解决scheme,所有的访问者(这是所有这些匿名访问者不必要的性能打击)。 对于参考点,我使用了基于这个由四个厨房提供的缺省Drupal敏感示例的Varnish vcl: https ://fourkitchens.atlassian.net/wiki/display/TECH/Configure+Varnish+3+for+Drupal +7

Nginx htaccess重写指定的文件夹

我试图将这个htaccess规则转换为nginx: 阿帕奇 # Necessary to prevent problems when using a controller named "index" and having a root index.php # more here: http://httpd.apache.org/docs/2.2/content-negotiation.html Options -MultiViews # Activates URL rewriting (like myproject.com/controller/action/1/2/3) RewriteEngine On # Disallows others to look directly into /public/ folder Options -Indexes # When using the script within a sub-folder, put this path here, […]

通过.htaccess更改MaxRequestLen的值?

是否有可能改变MaxRequestLen的价值没有根访问我的Apache 1and1.co.uk专用服务器(托pipe版本)? 我希望能够通过.htaccess更改值? 有谁知道这是可能的吗? 我调查了是否可以通过php.ini文件更改该值,但MaxRequestLen是服务器configuration而不是PHPvariables。 请注意服务器上启用了纯CGI(服务器没有快速CGI)。 更新: <IfModule mod_fcgid.c> MaxRequestLen 31457280 </IfModule> 会这样的工作在.htaccess?

Apache SSLredirect循环

我们正试图将我们的网站从httpredirect到https。 我们在.htaccess中试过的所有东西都导致了redirect循环。 如果我们手动在url前input“https://”,我们的页面会返回jQuery error! 。 所以我怀疑这是不是所有请求的资源都通过https请求? 我们的htaccess文件: RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] # change rewrite base if not in root RewriteBase / # api RewriteRule ^(api)($|/) – [L] # index.php RewriteRule ^index.php$ – [L] # pass-through RewriteRule ^(css|js|site)/.*$ – [L] # redirect errors ErrorDocument 400 /error/400/ ErrorDocument 401 /error/401/ ErrorDocument 403 […]

htaccess规则的URL不以某些单词结尾

我需要重写几个url,如果这些url没有结束某些单词。 例如,我需要重写下面的url /category1/subcategory1/aproduct-url-title to /category1/fixedword/aproduct-url-title 重写不应该发生在下面的url上,因为这些链接以某些特定的词结束(view-all,p10,p20,p30,从低到高,从高到低) – /category1/subcategory1/view-all /category1/subcategory1/p10 /category1/subcategory1/p20 /category1/subcategory1/low-to-high /category1/subcategory1/high-to-low 我试着用下面的规则没有成功 – RewriteRule ^(category1|category2)\/(.*)\/(!p[0-9]+|view-all|low-to-high|high-to-low)$ /$1/fixedword/$3 我也试过以下规则 – RewriteCond %{REQUEST_URI} !(p[0-9]+|view-all|low-to-high|high-to-low)$ RewriteRule ^(category1|category2)\/(.*)\/(.*)$ /$1/fixedword/$3 感谢你的帮助。 谢谢

mod_expires不设置图像到期(PNG,JPEG,GIF)

我在我的apache2.conf中使用下面的configuration <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/gif "access plus 6 month" ExpiresByType image/jpg "access plus 6 month" ExpiresByType image/jpeg "access plus 6 month" ExpiresByType text/javascript "access plus 6 month" ExpiresByType text/css "access plus 6 month" ExpiresDefault "access plus 6 month" </IfModule> 它为css和js工作 curl -I example.com/assests/css/global.css Expires: Wed, 14 Jan 2015 09:28:17 GMT 但是当我curl任何图像文件 curl -I […]

在负RewriteCond中包含多个文件

我使用这个规则来忽略重写规则中的index.php: RewriteRule ^((?!index\.php)[^/]+)/?$ galeria.php?nome=$1 [L,QSA,NC] 但是我需要在这个规则中包含bio.php和contact.php。 我怎样才能做到这一点?

.htaccess查询string阻塞phpmyadmin

phpmyadminlogin后,我得到这个错误信息 Error in Processing Request Error: 403 Error text: Forbidden" 我发现从.htaccess中删除以下行不会给出任何错误 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} (\"|%22).*(<|>|%3) [NC,OR] RewriteCond %{QUERY_STRING} (javascript:).*(\;) [NC,OR] RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3) [NC,OR] RewriteCond %{QUERY_STRING} (\\|\.\./|`|=\'$|=%27$) [NC,OR] RewriteCond %{QUERY_STRING} (\;|\'|\"|%22).*(union|select|insert|drop|update|md5|benchmark|or|and|if) [NC,OR] RewriteCond %{QUERY_STRING} (base64_encode|localhost|mosconfig) [NC,OR] RewriteCond %{QUERY_STRING} (boot\.ini|echo.*kae|etc/passwd) [NC,OR] RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC] RewriteRule .* – [F] 我已经尝试将RewriteCond %行1 […]