我把Apache Server Configs全局.htaccess文件放在我的Web服务器上,如/etc/apache2/apache-server-configs.conf 。 然后在我的/etc/apache2/apache2.conf文件中,我已经得到了这个文件的结尾: # Include of directories ignores editors' and dpkg's backup files, # see the comments above for details. # Apache Server Configs Include apache-server-configs.conf # Include generic snippets of statements Include conf.d/ # Include the virtual host configurations: Include sites-enabled/ 正在包含apache-server-configs.conf文件,但是这段代码无法工作: RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} […]
只要build立一个FreeBSD jail来运行httpd,除了这两个重写/代理模块之外,所有的工作都很好。 这些是错误日志摘录: mod_rewrite错误: [重写:暴击] [pid 43447](13)权限被拒绝:AH00666:mod_rewrite:无法初始化rewrite_mapr_lock_acquire mod_proxy错误: [代理:暴击] [pid 43447](13)权限被拒绝:AH02479:无法初始化proxy_mutex在小孩 不能确定什么被拒绝的文档根目录中的HTML服务就好了,当这些模块被禁用。 我尝试了Googlesearch,但没有发现垃圾。
呃,我在想,我无法弄清楚,我很沮丧: <VirtualHost *:80> servername domain1.com.au ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Proxy *> Order Allow,Deny Allow from all </Proxy> RewriteEngine on ReWriteCond %{SERVER_PORT} !^443$ RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] </VirtualHost> <VirtualHost *:443> servername domain1.com.au SSLEngine on SSLCertificateFile /etc/apache2/ssl/owncloud.pem SSLCertificateKeyFile /etc/apache2/ssl/owncloud.key DocumentRoot /var/www/html </VirtualHost> <VirtualHost *:*> Servername domain2.com.au ProxyRequests Off <Proxy *> Order deny,allow […]
正如Wordpress编解码器中所解释的,我想通过RewritetRule来防止对wp-login.php的暴力攻击。 http://codex.wordpress.org/Brute_Force_Attacks#Deny_Access_to_No_Referrer_Requests 我想重写为403 Forbidden状态,而不是Codex的301状态码,并将其logging为“ 客户端被服务器configuration拒绝 ”,以便Fail2Ban可以处理日志并阻止IP。 我正在使用下面的代码。 # Stop spam attack logins and comments <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_METHOD} POST RewriteCond %{REQUEST_URI} .(wp-comments-post|wp-login)\.php* RewriteCond %{HTTP_REFERER} !.*example.com.* [OR] RewriteCond %{HTTP_USER_AGENT} ^$ RewriteRule (.*) – [R=403,L] </ifModule> 它禁止POST攻击作为403状态码,但是我没有看到有关error_log发生的任何日志。 我如何使RewriteRulelogging正常的发生率403loginerror_log? 而且是Rewrite + Fail2Banconfiguration来处理有效的服务器pipe理的蛮力攻击还是不行?
PS:这是最初发布在这里的问题的第二部分。 我想为特定的虚拟主机完全禁用HSTS标头 。 我有(每个build议 )在443容器中为这些虚拟主机中的每一个redirect。 它工作正常,但Apache 不build议使用RewriteRule,除非绝对必要。 是否有可能执行下面的redirect只使用redirect ,而不是重写? <VirtualHost xxxx:443> <IfModule mod_headers.c> Header unset Strict-Transport-Security Header always set Strict-Transport-Security "max-age=0;includeSubDomains" </IfModule> SuexecUserGroup "#520" "#520" ServerName dev.domain.com ServerAlias www.dev.domain.com ServerAlias subdomainjr2b.dev.domain.com ServerAlias www.subdomainjr2b.dev.domain.com ServerAlias subdomainblah.dev.domain.com ServerAlias www.subdomainblah.dev.domain.com RewriteEngine On RewriteRule ^(.*)$ http://%{HTTP_HOST}$1 [redirect=302] PS1:Domain.com有一个通配符证书,通配符只适用于sub.domain.com,而不是sub.sub.domain.com,因此需要禁用这些虚拟主机的hsts。 PS2:不要问我为什么我需要使用Header unset当我已经使用Header always set 。 它是在实现Header unset之前向客户端发送两个头文件,并且从我理解的不应该这样做 。
有一个GIF的问题,失去了animation,我正在重写。 RewriteRule ^journal/(.+)\.(jpeg|jpg|png|mp4|webm|ogv)$ app/uploads/journal/$1 [QSA,L] RewriteRule ^journal/(.+)\.(gif)$ app/uploads/journal/$1 [QSA,L,T=image/gif] 出于某种原因,它仍然与图像/ JPEG标题。 任何想法为什么? 重写日志
我有一个WordPress安装在/var/www/wordpress/和我自己的代码在/var/www/project/ 现在出现以下问题:当我尝试访问example.com/client/或example.com/admin/ ,应该链接到/var/www/project/并从那里执行.htaccess + index.php。 我试图在部分成功的Apacheconfiguration中放置一个Alias指令。 Alias /admin/ /var/www/project Alias /client/ /var/www/project 当我访问example.com/client/它可以正常工作,但只要我请求example.com/client/login就会失败,并且File does not exist: /var/www/project/login error。 /var/www/project的.htaccess看起来像 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/(.*)$ index.php?module=$1&task=$2 [L,QSA]
在我的灯安装,我已经在根文件夹“/”(mydomain.org)W3总caching激活wordpress多站点,我也有一个sub_dir称为“ 子 ”(mydomain.org/sub)与PHP脚本里面。 我有一些sub_dircaching问题,所以我想设置一个RewriteRule从我的sub_dir中排除W3总caching ,问题是,我只有这方面的基本知识。 我的根的htaccess … # BEGIN W3TC Minify cache <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^[_0-9a-zA-Z-]+/wp-content/cache/minify/[0-9]+/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 [L] </IfModule> # END W3TC Minify cache <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} […]
最近我一直在我的网站的日志中find一些引荐垃圾邮件。 为了阻止这个(因为它非常烦人,也污染我的统计),我想阻止来自某些引用域的请求。 可以find很多文章,build议在网站的.htaccess文件中放入以下(或类似的东西): RewriteEngine On RewriteCond %{HTTP_REFERER} example\.com [NC] RewriteRule .* – [F] 这工作得很好,但是,我想将其移到Apacheconfiguration,以便将此重写规则应用于服务器上托pipe的所有网站。 我也读过这对性能更好,因为必须为每个请求parsing.htaccess文件,而Apacheconfiguration只加载一次。 我的服务器在Ubuntu上运行,所以我创build了一个新的.conf文件:/etc/apache2/conf-available/block-referrer-spam.conf,其内容与上面的.htaccess代码片段完全相同。 我在启用conf的目录中创build了一个符号链接(使用sudo a2enmod block-referer-spam )并重新加载了Apacheconfiguration( sudo service apache2 reload )。 但是,与使用.htaccess不同,Apache不会阻止请求(返回403)。 我想我可能会忽略简单的东西,所以任何帮助表示赞赏。
我们有一些子域名的设置,我想简化一些Apacheconfiguration – 特别是这些特定的子域名是不稳定的。 无论如何,我试图得到一个重写规则,包括主机。 到目前为止,我有: RewriteEngine On RewriteCond %{HTTP_HOST} ^(.*).net.au$ RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%1.net.au$1 [R=302,L] 这是基于https://stackoverflow.com/questions/3634101/url-rewriting-for-different-protocols-in-htaccess和http://httpd.apache.org/docs/2.4/rewrite/vhosts.html 但是,第一种情况下的模式并没有写入重写的地址,我最终被发送到.net.au /任何地方(不会让我用https在前面发帖) – 我错过了什么? 在Ubuntu 14.04上运行apache 2.4