Articles of .htaccess

我的.htaccess文件是什么意思?

我的.htaccess说: # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> AuthName eigos.co.nz AuthUserFile /home/bob/public_html/_vti_pvt/service.pwd AuthGroupFile /home/bob/public_html/_vti_pvt/service.grp 有人能告诉我这是什么吗?

.htaccess目录噩梦

我在一个shell中,我的web文件夹位于/home/w/waterfox/public_html 。 在那里,我有一个名为irclogs ,我试图密码保护。 它被修改为755。 这里是我放在我的public_html文件夹中的.htaccess文件: <Directory /home/w/waterfox/public_html/irclogs> AuthUserFile "/home/w/waterfox/public_html/.htpasswd" AuthType Basic AuthName "Restricted" Require valid-user </Directory> 当我尝试访问我的网站的任何部分,包括irclogs文件夹以外的东西,我得到一个500 Internal Server Error 。 这似乎与我的.htpasswd文件没有任何关系,因为我可以使用<Files>或<FilesMatch>来保护单个文件。

启用.htacess中的ReWriteLog后,我无法打开我的网站。

.htaccess首先运行良好,然后在我的.htacess中添加了两行来启用RewriteLog。 结果是我没有打开我的网站。 我添加到我的.htaccess的两行如下: RewriteLog /home/bigmeow/mylog/rewrite.log RewriteLogLevel 9 启用rewritelog的.htaccess如下所示: less .htaccess RewriteEngine On RewriteBase /blog/ RewriteLog /home/bigmeow/mylog/rewrite.log RewriteLogLevel 9 RewriteRule ^index\.php$ – [L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [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} -d RewriteRule ^ – [L] RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L] […]

隐藏直接访问URL时显示的目录内容

在我的网站上,如果您浏览到http://example.com/images/ ,整个目录的内容如下所示: 我怎么能这样做,这不会发生? 我可以在该目录下创build一个.htaccess文件吗? 或者,还有更好的方法? 我真的想阻止整个网站(即该网站上的每个目录)的目录列表。 我认为这是要做的事情在Apache或使用全球.htaccess文件,并将其放置在public_html文件夹中,也许? 编辑 我使用index.php文件转移了这个,但是我仍然觉得安全性是一个问题,我怎样才能永久解决这个问题?

htaccess的位置

我需要编辑我的服务器上的htaccess文件。 问题是,我找不到它。 任何想法会在哪里?

强制HTTPS时redirect循环

我正在使用以下内容在我的主网站上强制使用HTTPS。 ### Force SSL RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 如果你想查看完整的htaccess文件,我已经把它放在下面: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / ### Blacklist via Referrers RewriteCond %{HTTP_REFERER} removed\.net [NC,OR] RewriteCond %{HTTP_REFERER} removed\.com [NC,OR] RewriteCond %{HTTP_REFERER} removed\.removed\.com [NC,OR] RewriteCond %{HTTP_REFERER} removed\.com [NC,OR] RewriteCond %{HTTP_REFERER} removed\.net [NC,OR] RewriteCond %{HTTP_REFERER} removed\.sx [NC,OR] RewriteCond %{HTTP_REFERER} removed\.com [NC,OR] RewriteCond %{HTTP_REFERER} removed\.com [NC,OR] RewriteCond […]

使用Elastic Beanstalk的自定义环境属性进行htaccess

有没有办法在htaccess中使用弹性beanstalk的自定义环境属性? 我只想在不在本地运行时将http重写为https,所以我想我可以通过使用elastic beanstalk的环境属性来做到这一点。 RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

htaccess的问题

我在.htacess中有几行 Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^mydomain.org [NC] RewriteRule ^(.*)$ http://www.mydomain.org/$1 [L,R=301] # index.php to / RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /.*index\.php\ HTTP/ RewriteRule ^(.*)index\.php$ /$1 [R=301,L] # forum RewriteCond %{REQUEST_URI} !^/forums/ RewriteRule index.php/(.*) http://forum.mydomain.org/$1 [R=301,L] 这个代码运作良好,但我不知道如果代码是标准的。 我想设置htaccess: * mydomain.org go to www.mydomain.org (its ok..) * mydomain.org/index.php go to www.mydomain.org (its ok..) * forum.mydomain.org stay forum.mydomain.org […]

.htaccessbuild议为新网站caching做准备

目前我的网站有caching控制设置为JavaScript库和图像,并caching他们一个星期。 我想知道什么最佳做法,我应该导致我的网站在一周内重新启动。 所有的图像,JavaScript,CSS文件将被取代。 我正在考虑的几个策略: 将ExpiresByType更改为下一周的一个小时,以确保返回的访问者不会有较慢的速度,然后在启动之前1.5小时,将caching控件更改为零。 将ExpiresByType更改为零直到启动。 从htaccess中删除所有caching控件,直到启动,并让浏览器处理caching。 对上述策略或者我没有考虑过的事情有什么想法? 谢谢 这是我的根.htaccess。 适用于图像和javasript库: ExpiresActive on ExpiresByType image/jpg "access plus 1 week" ExpiresByType image/png "access plus 1 week" ExpiresByType image/gif "access plus 1 week" ExpiresByType image/jpeg "access plus 1 week" ExpiresByType text/javascript "access plus 1 week" ExpiresByType application/x-javascript "access plus 1 week" ExpiresByType application/javascript "access plus 1 week" […]

一些mod_rewrite的语法澄清

我们最近inheritance了一些代码,并且正在审查其中一个站点的.htaccess文件。 我知道大部分重写规则集的最终结果是什么,我只是不确定一些语法。 背景信息:使用Apache 2.4的CentOS 7,运行Concrete5 CMS。 例1: RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 据我所知,%{HTTPS}是mod_rewrite提供的特殊variables之一,可以on或off 。 在之前的规则中,我看到了RewriteCond %{HTTPS} =on这更符合文档中显示的内容。 所以在上面的例子中,我有以下问题: %{HTTPS}中的结尾“s”是什么? 为什么模式使用^ on而不是= on。 这有效吗? 我明白,括号中的任何内容都可以用%1来引用,但这里的放置对我来说并不合适。 如果%{HTTPS}计算为on或off ,则放置(s)| 在模式是要使它不符合条件,对不对? PIPE是什么? 例2: #redirect calls to index.php without get parameters to non-www RewriteCond %{REQUEST_METHOD} !=POST RewriteCond %{THE_REQUEST} /index\.php\s [NC] RewriteRule ^(.*?)index\.php$ /$1 [L,R=301,NC,NE] 我不太理解第二个RewriteCond。 index.php最后做了什么? 例3: 最后,我们有 […]