Articles of .htaccess

Ganglia私人页面

我已阅读关于授权系统的Ganglia文档( https://github.com/ganglia/ganglia-web/wiki/Authorization-System )。 我想限制所有通过htaccess访问页面,所以只有经过身份validation的用户才能访问它。 一个.htaccess文件与“要求有效的用户”的neural network是足够的?

使用Apache mod_rewrite将主机重写到子文件夹,但redirect而不是重写

我想通过.htaccess模拟虚拟主机,所以我想重写主机名到子文件夹。 它工作,但在一些URL不重写,但redirect。 这是我的.htacess文件: RewriteEngine on RewriteBase / # Rewrite from subdomains to subfolders with builds RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.ci\.example\.com$ RewriteCond %{REQUEST_URI} !^/builds/ RewriteCond %{REQUEST_URI} !^/robots.txt RewriteRule ^(.*)$ /builds/%2/%1/$1 [PT] # Example project RewriteCond %{HTTP_HOST} ^old\.domain\.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] # Rewrite production to master subfolder RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteCond %{REQUEST_URI} !^/builds/ […]

.htaccess只能redirect到首页?

我的网站有更多的语言,我想这样做redirect每种语言,例如:/ es / to / es,简单的redirect,但这种方法使问题的子页面,我怎么能告诉htaccess使用这个规则只为主页?

无法获得包含的CSS和JS文件被压缩

我通过.htaccess和httpd.conf启用了压缩 但是,当我通过各种在线testing人员运行它时,总是说包含的各种文件没有被压缩。 Apache版本是2.2.15 .htaccess目前看起来像这样: ## EXPIRES CACHING ## ExpiresActive On ExpiresByType image/jpg "access 1 year" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/gif "access 1 year" ExpiresByType image/png "access 1 year" ExpiresByType text/css "access 1 month" ExpiresByType application/pdf "access 1 month" ExpiresByType application/x-shockwave-flash "access 1 month" ExpiresByType image/x-icon "access 1 year" ExpiresByType application/javascript "access 2 days" […]

Nginx,将所有resquestredirect到子文件夹中的单个index.php文件

我试图把我的网站从Apache移动到Nginx。 我的网站是这样构build的: www_root 上市 其他文件夹 所有请求都使用.htaccess从www_rootredirect到公用文件夹,其中包含: RewriteRule ^$ public/ [L] RewriteRule (.*) public/$1 [L] 在公共文件夹中 ,所有的请求都被redirect到单个入口点index.php .htaccess: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?page=$1 [QSA,L] 目前我的服务器块是这样的: server { server_name domain.com www.domain.com; root /var/www/domain.com/htdocs/public; location / { # try to serve file directly, fallback to index.php try_files $uri /index.php$is_args$args; } location ~ ^/index\.php(/|$) { […]

在上菜之前先使用varnish检查html静态

我正在考虑编写一些逻辑到我的应用程序,以便它可以将静态页面内容写入s3或某个CDN,并主要从那里开始。 但是我不确定这是否可能。 例如,我有site.com/something,它应该首先在cdn中查找,如果不存在,则从varnishcaching或nginx / php-fpm提供服务。 这个想法是把stream量从服务器上拿走。 这是一个可能的情况? 在drupal中,我看到了一个模块来做到这一点 。 它将静态文件caching存储在磁盘中,并在其中存在。 下面是他们提供的图表。 他们问下面的.htaccess除外 # RewriteBase / ### BOOST START ### # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support) RewriteRule .* – [E=boostpath:normal] # Caching for anonymous users # Skip boost IF not get request OR uri […]

如何在文件和子目录中启用Apache DIGEST Authentivation

我正在尝试许多不同的configuration,下面有很多教程和文档,如果不创build数千个.htaccess文件,我就无法获得authentication。 这是我的configuration: <VirtualHost *:443> DocumentRoot /home/user/www ServerName preprod.user.com <Directory /home/user/www> Options Indexes SymLinksIfOwnerMatch AllowOverride All AllowOverride FileInfo AuthConfig Limit Require all granted </Directory> SSLEngine on SSLCertificateFile /etc/ssl/private/preprod.user.com.crt SSLCertificateKeyFile /etc/ssl/private/preprod.user.com.key </VirtualHost> 在根目录下,我写了这个/home/user/www/.htaccess文件: AuthType DIGEST AuthName "preproduction" AuthDigestNonceLifetime 1 AuthDigestDomain "/home/user/www/" "https://preprod.user.com/" AuthDigestProvider file AuthUserFile "/web/auth/.digest_pw" Require valid-user 结果是: https://preprod.user.com/ asks for a password https://preprod.user.com/v1/ asks for […]

Apache:由于可能的configuration错误,请求超出了10个内部redirect的限制 – WooCommerce

我有一个woocommerce网站。 我在Apache error.log中有一个recursion错误: [Mon Nov 02 17:04:58.723578 2015] [core:error] [pid 2922] [client 172.31.12.207:19044] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: https://gremyo.com/wp-content/themes/bishop/woocommerce/style.css [Mon Nov 02 17:04:58.812460 2015] [core:error] [pid 2928] [client 172.31.12.207:19045] AH00124: […]

阻止假的谷歌机器人

我怎样才能用假的Google机器人阻止DDOS攻击? 我在网上find了两个解决scheme。 但两者似乎也阻止了正确的谷歌机器人。 # Block fake google when it's not coming from their IP range's (A fake googlebot) [F] => Failure RewriteCond %{HTTP:X-FORWARDED-FOR} !^66\.249\.(6[4-9]|[78][0-9]|9[0-5])\. RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5\.0\ \(compatible;\Googlebot/2\.[01];\ \+http://www\.google\.com/bot\.html\)$ [NC] RewriteRule .* – [F,L] # End if match 这是第二个: # Validate Googlebots RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5\.0\ \(compatible;\ Googlebot/2\.[01];\ \+http://www\.google\.com/bot\.html\)$ RewriteCond %{HTTP:Accept} ^\*/\*$ RewriteCond %{HTTP:Accept-Encoding} ="gzip,deflate" RewriteCond […]

如果匹配.htacces中的特定正则expression式,将页面redirect到410

第一次使用.htaccess所以我来这里有一些帮助,因为networking是不是与信息的文件(或者我只是没有find他们:/)。 所以我的想法是,我想redirect以/2/或/3/ …(数字)结尾的链接到error410页面。 所以我想出了这个正常工作的正则expression式^(.*?)\/(?!(?:404|410)$)\d+$ 在这里testing 如果我知道这是如何工作,这是正确的解决scheme: RewriteCond %{QUERY_STRING} ^(.*?)\/(?!(?:404|410)$)\d+$ [NC] RewriteRule . – [G] 你认为这会起作用吗? 我不想玩学徒精灵