Articles of .htaccess

Apache不响应configuration更改

我有一台运行在Ubuntu 12.04.4 LTS上的最新2.2版本的Apache服务器。 我没有改变大部分的configuration。 一切正常开始,但现在它没有注意到其configuration的任何改变。 例如,这里是一个.htaccess文件。 <IfModule mod_rewrite.c> RewriteEngine on RewriteRule myfile [F] Header set X-Asdf rewrite_found </IfModule> 这完全没有效果(即使我有mod_rewrite ),在.htaccess也没有任何其他的东西。 另外,我把这个添加到httpd.conf : ServerSignature Off ServerTokens Prod 根本没有效果。 我试过这些东西,没有任何影响: service apache2 reload service apache2 restart 重启机器 添加到httpd.conf : <Directory *> AllowOverride All </Directory> Apache仍然在读取configuration,因为任何语法错误会在重新载入时报告错误。 什么可能导致这个? 编辑: root@my-server:~# apachectl -S VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: […]

mod_alias.c规则redirect所有子目录

这里是一个mod_alias新手。 我发现重写规则下面的地方,并已经用它来阻止机器人和黑客打我的网站,寻找像HNAP1 , HNAP1 , blog等目录。 它的作品,返回一个Forbidden 403消息。 <IfModule mod_alias.c> RedirectMatch 403 /(\{\$itemURL\}|cro|HNAP1|wp|blog|)/?$ </IfModule> 但我怎么也redirect/wp/wp-admin/和/blog/wp-admin/到403消息? 和其他任何子目录,即/wp/wp-admin/subdirectory/ ?

如何使用htaccess&apache重写/ page到/ xx / page?

您好我已经find了许多mod-rewrite和Apache的资源,但我还没有成功的做一个工作的例子。 下面的例子适用于 ✓WORKS example.com/en/page1.php☞example.com/page1.php?ln=en (内部redirect) ✓WORKS example.com/page1.php☞example.com/en/page1.php (redirect) ✓WORKS example.com/en/☞example.com/index.php?ln=en (内部redirect) ✓WORKS example.com/☞example.com/en/ (redirect) ✓WORKS example.com/blahblah☞example.com/en/error.php (redirect) ✓WORKS example.com/zh/blahblah☞example.com/zh/error.php (redirect) ✖FAILS example.com/de☞example.com/en/error.php (redirect – 应该是example.com/de/ ) ✖失败example.com/de/blahblah☞example.com/en/error.php (redirect – 应该是example.com/de/error.php ) <IfModule mod_rewrite.c> RewriteEngine On DirectorySlash On # Force hostname without www REDIRECT RewriteCond %{HTTP_HOST} !^example\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^(.*)$ http://%1/$1 [R=301] # […]

.htaccess规则阻止DDoS POST泛滥

我们受到来自如下stream量的分布式拒绝服务攻击: 49.146.161.175 – – [11/Jul/2014:00:43:42 -0400] "POST / HTTP/1.1" 500 557 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" 117.221.185.108 – – [11/Jul/2014:00:43:42 -0400] "POST / HTTP/1.1" 500 557 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" 58.186.16.180 – – [11/Jul/2014:00:43:42 -0400] "POST / HTTP/1.1" 500 557 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows […]

htaccess和重写 – 内部redirect在别名

我有一个子目录下面的.htaccess : RewriteEngine on RewriteRule ^file.js$ file.php 包含上述和其他文件的目录如下所示: dir/ ├── index.html └── js ├── file.php └── .htaccess 我想我的file.js被内部redirect到file.php 。 当我在/var/www/html/ dir下finddir ,我的vhost定义如下所示: DocumentRoot /var/www/html <Directory "/var/www/html"> AllowOverride All Require all granted </Directory> #Alias /dir "/tmp/dir" #<Directory "/tmp"> # AllowOverride All # Require all granted #</Directory> 它的作品 ! 但是,当我将dir移动到/tmp/并将vhost更改为如下所示: DocumentRoot /var/www/html #<Directory "/var/www/html"> # AllowOverride All […]

Apache:隐藏404pipe理区域,直到通过基本身份validation进行身份validation,然后允许访问

给定一个像这样的URL的行政区域: wp-admin/ wp-admin/whatever wp-admin/another-page wp-adminsecretlogin 标准的基本身份validation覆盖将在所有三个url上提供用户名和密码提示,并在所有失败的auth尝试中返回403。 这是一个非常明显的信号,表明在那里存在某些东西,因此是脚本/暴力访问的邀请。 我想反而需要基本的身份validation无处不在,但是当未经过身份validation,不提示input用户名和密码,而是返回一个404找不到所有的URL错误,除了一个wp-adminsecretlogin/ url。 在个人到站点的URL中,基本的身份validation可以通过,并解锁其余的pipe理function(虽然标准的应用程序login仍然是必要的)。 我将如何通过Apache .htaccess或.conf指令来做到这一点?

.htaccess文件导致“500内部服务器错误”,但没有错误日志条目

我手动设置了一个apache,并添加了这个代码的第二个Web目录: Alias /webs c:\webs <Directory /webs> AllowOverride All </Directory> 但是,这个网站中有一个.htaccess文件,访问网站时出现错误:“500 Internal Server Error”,但是在错误日志文件中没有写入任何内容。 但是,当我删除.htaccess文件,我没有得到这个错误。 我添加了“AllowOverride All”行并重新启动服务器,但是这不能纠正错误。 我的.htaccess是这样的: RewriteEngine On RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?params=$1 [L,QSA] <Files "test"> Order Allow,Deny Allow from all </Files> 我有什么要做的,我可以在这个目录中使用.htaccess文件?

如何使用.htaccesscaching文件夹中的特定文件

我试图谷歌,并find了一个解决scheme' https://webmasters.stackexchange.com/questions/24881/cache-a-particular-image-using-htaccess ',但它caching文件夹的所有文件,我只想caching特定文件夹中的文件。 请帮帮我 提前致谢。

为什么Apache提供.htaccess文件

我注意到我的apache系统正在提供.htaccess文件,但它不应该,因为: # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # <Files ~ "^\.ht"> Order allow,deny Deny from all </Files> 这是默认的Apacheconfiguration。 我有许多虚拟主机下面。 我怎样才能找出为什么Apache仍然提供.htaccess文件? 背景:尝试添加一个目录指令来阻止.svn文件夹,同时想知道为什么Apache不会阻止他们,我遇到了这个问题:它根本不阻止任何东西,甚至没有默认的.htaccess mod_authz_host加载到/etc/apache2/mods-enabled/authz_host.load LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so

Apache别名链接到另一个DocumentRoot

我有一个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]