Articles of .htaccess

将301子域redirect到相同的子域,但在新文件夹中

我想301子域名redirect到相同的子域,但在一个新的文件夹。 所以我想将http://sub.example.com/(.*)redirect到http://sub.example.com/folder/ 但是当我去folder页面不打开。 备注 : 我把主要子域中的.htaccess 。 我也得到一个redirect循环。

Apache2基本authentication:user @ ip,user2 @ ip2 – 这可能吗?

我正在寻找客户在办公室远程办公时使用的外部服务。 假设:我的办公室IP和客户办公室IP都是静态的。 我希望允许我的客户访问服务,例如HTTP基本身份validation安全pipe理应用程序。 在Apache Basic Auth中有没有办法创build基于User @ IP的限制? 我想要: 我@ my_office 我@ my_home client1 @ their_office1 client2 @ their_office2 为了testing,我尝试了这个代码: <Location /> Satisfy All AuthType Basic AuthName "Authorisation" AuthUserFile /etc/apache2/passwd Order deny,allow Deny from all Allow from 10.0.0.1/32 Require user me Order deny,allow Deny from all Allow from 10.0.0.2/32 Require user client1 </Location> 用[[email protected]]testing允许访问,成功。 用[[email protected]]testing允许访问,失败。 […]

htaccess自定义403阻止IP错误错误不起作用

我试图阻止每个人,但我的网站上运行apache和centos的服务器上的一个IP地址。 我的设置如下。 我的服务器: `http://www.myserver.com/` 我的.htaccess文件 <limit GET> order deny,allow deny from all allow from 176.219.192.141 </limit> ErrorDocument 403 http://www.google.com ErrorDocument 404 http://www.google.com 当我从一个无效的IP访问http://www.myserver.com/ ,它给了我一个通用的403错误。 当我访问http://www.myserver.com/page-does-not-exist/它正确地redirect到http://www.google.com但我不明白为什么403错误不会redirect我也是。 有人有主意吗?

阻止所有用户无引荐者,但允许Googlebot / bingbot在同一时间(使用.htaccess)

由于一些业余的DDOS攻击我的网站,我不得不否认一些交通.htaccess工作正常。 不幸的是,它也阻止了googlebot / bingbot: order allow, deny deny from 54. SetEnvIfNoCase Referer "^$" bad_user SetEnvIfNoCase User-Agent "^Wget" bad_user Deny from env=bad_user 它只是阻止来自54.xxx整个stream量(只有来自它的stream量来自受感染的亚马逊云 – 我知道我可以排除亚马逊云只有30个IP范围,而不是整个54.xxx但我需要快速解决scheme)。 其余的机器人(大多数来自中国,台湾等)不使用引用,所以: SetEnvIfNoCase Referer "^$" bad_user 阻止他们。 但它也有一个副作用 : 当有人通过书签访问我的页面,或者直接input到浏览器(例如他在名片上显示红色)时,他将不会看到我的网站。 Googlebot,bingbot(以及其他不太重要的机器人)通常也不使用引荐来源。 #1是一个不便,但#2是一个真正的问题,我必须迅速解决。 我发现对我来说重要的机器人使用这些标签: 66.249.64.119 – – […] "GET /robots.txt HTTP/1.1" 403 534 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 66.249.64.119 – – […] "GET […]

根据首选语言(Accept-Language)redirect.htaccess

当用户请求/ ,我想redirect到/en或/de ,这取决于他们在HTTP请求头Accept-Language指定的首选项。 我想这是服务器端脚本很容易,但我需要一个.htaccess解决scheme,因为它必须为静态网站工作。 我试过的: mod_negotiation (使用types映射或MultiViews选项): 用户获得他们的首选语言, 但他们不会被redirect。 mod_rewrite ( RewriteCond %{HTTP:Accept-Language} ): 用户被redirect, 但他们不(必须)获得他们的首选语言。 (‡也不保证语言的质量值大于0,也不会在两种语言用不同的质量值指定的情况下find首选的语言。) 有这个解决scheme吗? 不pipe是以某种方式使内容协商redirect,还是允许在RewriteCond指令中检查/比较质量值,或者完全不同的东西。

问题与configuration代理

我有一个代理configuration问题。 我有以下.htaccess : Options -Indexes +FollowSymLinks -MultiViews # BEGIN Expire headers <IfModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 5 seconds" ExpiresByType image/x-icon "access plus 2592000 seconds" ExpiresByType image/jpeg "access plus 2592000 seconds" ExpiresByType image/png "access plus 2592000 seconds" ExpiresByType image/gif "access plus 2592000 seconds" ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds" ExpiresByType text/css "access plus 604800 […]

CentOS 6.8,Apache 2.2,稳定多年,突然间mod_rewrite似乎失败了

我有一个稳定多年的设置。 突然间,我得到的文件不应该存在于应该由mod_rewrite处理的项目上的Apache错误日志。 昨天晚上,我做了一个PHP / MySQL(不是Apache)的包更新,但我回滚了,它仍然有问题。 .htaccess和apacheconfiguration没有被触及。 我仍然在寻找线索,但到目前为止我几乎没有任何线索。 看起来像我们从本地networking(这是一个不同的服务器托pipe的networking)内的任何东西都没有问题。 如果我从我的手机打开了无线,我有时看到问题。 所有的文件不存在的path是有效的mod_rewrite处理。 我可以打他们没有问题。 有点困惑,并在接下来要寻找什么。 我inheritance了这个configuration,我试过不去碰它,但是这里是我们为这个虚拟主机准备的。 RewriteEngine on RewriteCond %{HTTP_HOST} !^www.domain.com RewriteRule ^(.*)$ http://www.domain.com$1 [R=301,L] 在公共文件夹中也有一个.htaccess与很多configuration。 这是一个相关的块: RewriteEngine On RewriteBase / #Correct some bad external links RewriteRule ^lh$ / [L,R=301] <FilesMatch "^cart$"> ForceType application/x-httpd-php </FilesMatch> 我已经把mod_rewritelogging到了9,并且匹配了apache错误日志中的一个请求。 init rewrite engine with requested uri /cart/ViewItem/6054668 applying pattern '^(.*)$' to uri […]

htaccess 似乎没有工作

我试图禁止访问任何与wordpress相关的内容 下面的不起作用,只是发射一个404: RewriteRule ^(.*wp-.*)$ – [L,F] 虽然如果我这样做,一切都很好: RewriteRule ^(.*wp-.*)$ whatever [L,R] 编辑:通过http://htaccess.madewithlove.be/检查显示没有问题。 编辑2:我看不出这是如何重复的mod_rewrite啧啧,显然我已经检查了它,不幸的是没有find解决办法。 编辑3:我能够确认它可以在我的本地虚拟机和其他临时服务器上工作,有没有办法在生产服务器上进行debugging? 编辑4:在评论中提供了修复,清楚地显示该解决scheme没有在“重复”的职位中提到,但是与默认的403错误页面丢失

将htaccess重写规则转换为Apache2虚拟主机规则

我试图通过结合一些.htaccess规则来设置通配符子域RewriteRule ,因为我相信我可以对我的Apache vhosts文件使用相同的规则。 实质上, example.com和www.example.com转到根path并查找index.php 。 所有其他(dynamic)子级别的请求,例如abc.example.com被重写(浏览器不可见)到example.com/process.php?p=abc 。 其次,基本/根级别之外的任何来自子域的文件的请求需要被重写为从没有子域的标准域的根path获得。 所以abc.example.com/css/style.css需要来自example.com/css/style.css 这是我的尝试。 我得到一个Apache错误: 您无权访问此服务器上的/index.php。 对于任何子域的尝试,除了www,其预期的工作,以及标准的example.com ,仍然工作正常。 <VirtualHost *:80> ServerAdmin [email protected] ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] ServerName other.example.com ServerAlias *.example.com DocumentRoot /var/www/example.com/public_html/ <Directory /var/www/example.com/public_html/> Options FollowSymLinks AllowOverride all Require all granted RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] RewriteCond […]

服务器在使用htacess时抛出LimitInternalRecursion错误

我对.htaccess挺.htaccess而我只是没有深入了解发生了什么事情。 服务器只是说,即使我看不到任何理由“redirect”,超过了10个内部redirect的限制。 它只发生在我尝试使用/users/Username , /users/显示一个错误,该用户无法find这是我想要的, /users/Username引发500内部服务器错误。 文件本身是好的,数据库检查也应该工作。 .htaccess文件是: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.php [L] IndexIgnore * ErrorDocument 400 / ErrorDocument 404 / RewriteRule ^users/([a-zA-Z0-9_-]+)/?$ users.php?id=$1 [NC,L]