Articles of .htaccess

除了使用.htaccess的一个path之外的每个URL强制使用SSL

我试图强制执行每个url除了第一个段/preview之外的SSL。 http://test.example.com/preview/blah/blah 应该被规则忽视; 每个其他的URL都应该被强制使用SSL。 我使用的是CentOS 6.4,Apache和CodeIgniter。 我的.htaccess文件: RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteCond %{REQUEST_URI} !^/preview/ RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] 通常,CI URL在被最后一条规则重写之前看起来像这样: http://test.example.com/index.php?/preview/blah/blah 我试过了: RewriteCond %{HTTPS} !=on RewriteCond %{REQUEST_URI} !^/index.php?/preview/ RewriteCond %{REQUEST_URI} !^/preview/ RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 那也行不通。 我究竟做错了什么?

.htaccess正在停止工作,而WP网站的工作,为什么?

我有三个站点在一个共享主机(Bluehost)中运行一个专用的IP地址。 说明如下: example.com =>这是主站点和域名,是一个WP example.net =>这是一个附加域名(不知道你是否熟悉这个术语),并正在运行另一个WP站点 subsite.example.net =>这是一个独立的PHP应用程序 每个WP都有它自己的.htacess文件,如下所示: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress 有了这个.htaccess文件,两个WP网站都可以正常工作,但独立的应用程序却没有。 如果我删除.htaccess文件然后是相反的,独立的应用程序工作,但WP网站没有。 有没有可以帮助我find解决这个问题? 更新 我正在使用独立PHP应用程序的.htaccess文件的以下configuration: <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond […]

覆盖.htaccess文件中的IndexIgnore

我有IndexIgnore *在我不想允许目录列表的目录中。 现在,在一个子目录中 ,我想override父目录中定义的IndexIgnore指令并允许目录列表。 IndexIgnore的文档说 The IndexIgnore directive adds to the list of files to hide when listing a directory. 我如何允许这个子目录的目录列表?

无法弄清楚如何在Ubuntu上启用mod_rewrite

我觉得我已经做好了一切: josiah@BOX-OF-DOOOM:~$ sudo apache2ctl start apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName josiah@BOX-OF-DOOOM:~$ sudo a2enmod rewrite Module rewrite already enabled josiah@BOX-OF-DOOOM:~$ sudo apache2ctl restart apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName josiah@BOX-OF-DOOOM:~$ 然后在我的.htaccess(这是CodeIgniter): <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / […]

.htaccess需要铬而不是其他浏览器的密码?

我们在我们的网站上有.htaccess http://subdomain.site.com/ : AuthType Kerberos AuthName "Internet ID" require valid-user order deny,allow deny from all allow from all 在网站的子目录http://subdomain.site.com/subdirectory/我们有一个.htaccess: AuthType none Satisfy any 原因是在这个子目录/我们有不同的authentication机制,不想使用Kerberos作为authentication。 但问题是,在Chrome中.htaccess身份validation仍然popup,但Firefox,歌剧,IE浏览器不加载页面之前提示进行此身份validation。 我无法理解服务器端configuration如何根据浏览器以不同方式呈现给最终用户? 我的子目录.htaccess中有什么东西我失踪了?

了解.htaccess

我需要了解.htaccess如何工作。 你能给我一些指针,关于.htaccess如何工作的教程? 另外,来自htaccess文件的脚本语言是“有趣的”。 这是关于什么的?

应该将Apacheconfiguration放入apache conf或.htaccess中吗?

我一直想知道什么是更有效的使用configuration例如在虚拟主机的conf文件上的mod_rewrite规则(加载一次,就是这样),或者把它放在目录本身的.htaccess文件,作为我了解加载和每个请求parsing文件。 这是错的吗? 我不明白Apache如何使用.htaccess文件吗?

使用.htaccess隐藏文件

比方说,我有我的公共目录中的index.php文件。 使用DirectoryIndex index.php ,我可以将该文件设置为我的网站中的默认索引。 但是如果我不希望用户通过www.example.com/index.php进入, 只能通过 www.example.com进入,我该怎么做? 编辑 我添加了下面的代码: if (strpos($_SERVER['REQUEST_URI'], 'index.php')) { readfile('404.html'); exit; } 在index.php的开头,这样通过www.example.com/index.phpinput会导致404错误,但是通过www.example.cominput不会(因此,不会给潜在的攻击者提供信息,使用PHP或不)。 不是世界上最好的解决scheme,但确实有效。

从root .htaccess重写规则中排除一个目录以允许它被密码保护?

上个星期我花了很多时间来解决这个问题,但不pipe我尝试了什么,我都无法把它工作。 我的网站主持人说,他们没有任何人对htaccess文件有足够的了解,以使其运行起来(鼓励,对吧?),而我从CMS购买CMS的公司也无法确定解决scheme。 我也在这里和其他网站上看过几十个答案,但是我根本无法解决我的问题。 这里的交易:我的CMS – Invision电源板 – 生成以下.htaccess文件,它位于网站的根目录: <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} .*\.(jpeg|jpg|gif|png)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . /public/404.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> 我有一个子目录sub_dir ,我需要在子目录中使用.htaccess文件进行密码保护。 我通过cPanel设置了密码保护,如果网站根目录下的.htaccess文件被禁用,它可以正常工作。 如果网站根目录下的.htaccess文件没有被禁用,那么当我浏览到sub_dir ,主页被显示。 起初,我认为显示的主页可能与404页面重写有关,但即使我删除了404页面的重写条件和规则,主页仍然显示。 sub_dir .htaccess文件中的sub_dir是: AuthUserFile "/home/[user]/public_html/.htpasswd" AuthType Basic AuthName "subdir" require valid-user 正如我之前提到的,密码保护在根目录中的.htaccess文件被禁用时起作用。 它也适用于当我删除底部重写条件和规则(index.php的行),但删除404页的重写条件和规则不影响任何东西。 […]

将多个域redirect到子文件夹并隐藏URL中的子文件夹

我已经坐在同一个ip和同一个文件根与Apache的虚拟主机,因为我想使用共享文件和文件根目录中的内容。 我希望我的第二个网站指向文档根目录的子文件夹 http://example.com Loads http://example.com/subfolder 我在.htaccess中尝试了各种重写规则,他们都可以redirect,但保持在我不喜欢的url中的子文件夹我的意思是url将是 http://example.com/subfolder 而我想要的 http://example.com 这些都是我所尝试过的 RewriteCond %{HTTP_HOST} ^(www.)?example.com$ RedirectMatch ^/$ http://example.com/subfolder 要么 RewriteCond %{HTTP_HOST} ^(www.)?example.com$ RewriteRule ^(.*)$ /subfolder/$1 [L] 第二个也给500内部服务器错误,我该怎么办?