Articles of .htaccess

htaccessredirect循环

我在下面的代码中导致redirect循环的最后一行的问题(至less这是我的想法) RewriteEngine On RewriteBase /jgel/ RewriteCond %{REMOTE_ADDR} !^172\.172\.121\.142 RewriteCond %{REQUEST_URI} !maintainance\.php RewriteCond %{REQUEST_URI} !resources/(.*)$ [nc] RewriteRule ^(.*)$ maintenance.php [R=307,L] 我已经尝试过,这也是行不通的 RewriteEngine On RewriteBase / RewriteCond %{REMOTE_ADDR} !^172\.172\.121\.142 RewriteCond %{REQUEST_URI} !maintainance\.php RewriteCond %{REQUEST_URI} !resources/(.*)$ [nc] RewriteRule ^(.*)$ /jgel/maintenance.php [R=307,L]

如何防止htaccess提示通过ajax间接访问文件的身份validation?

首先我的术语可能是错误的,但是当我听到“直接访问”时,我认为有人意味着任何人都已经从url中读取文件的权限。 我对“直接进入”是什么意思的理解是正确的? 我使用htaccess来防止直接访问以下目录(http目录是DocumentRoot /var/www/public_html ) <Directory /var/www/public_html/indirect_access/> AuthType Basic AuthName "Restricted Access" AuthUserFile /passwords/me Require user me </Directory> 我有两个文件 /var/www/public_html/indirect_access/indirect.php <?php echo 'hi'; ?> /var/www/public_html/direct.php <?php include('indirect_access/indirect.php'); ?> 当有人去www.mysite.com/direct.php,浏览器打印“嗨”。 当有人去www.mysite.com/indirect_access/indirect.php他们被提示input用户名和密码。 但是当我改变/var/www/public_html/direct.php的内容来包含一个AJAX请求 $.ajax({ url: "indirect_access/indirect.php", type: "GET", dataType: 'html', success: function(data){ $("body").prepend(data); }, }); 然后我尝试访问www.mysite.com/direct.php,提示input用户名/密码。 是否有可能阻止htpasswd提示通过ajax间接访问文件的身份validation?

在htaccess中优化mod_rewrite

我在.htaccess文件中得到了一些mod_rewrite的条件,但是我不认为它的写得很好(我对mod_rewrite还是比较新的) 有时候请求会以无限循环结束 而刚才我把SSL加到文件中.. 当请求https://我得到一个404错误The requested URL /_secure/_secure/ was not found on this server. 不知何故,它增加了一个额外的_secure的path? 的.htaccess # redirect non-active subdomain to 'www' RewriteCond %{HTTP_HOST} !^(admin|api|demo|files|secure|www)\.([^\.]+\.[^\.]+)$ [NC] RewriteRule ^(.*)$ http://www.domain.com [L,R=301] # put 'www' as subdomain if none is given RewriteCond %{HTTP_HOST} ^([^\.]+\.[^\.]+)$ [NC] RewriteRule ^(.*)$ http://www.%1/$1 [L,R=301] # redirect to subdomain RewriteCond %{HTTP_HOST} ^www\.([^\.]+\.[^\.]+)$ [NC] RewriteRule […]

htaccess与通配符SSL

我们有一个通配符SSL证书,应该在给定域的任何子域上工作。 所以在这个服务器上我们有这个文件结构: / home / DOMAIN / public_html / subdomainx / home / DOMAIN / public_html / subdomainy等… 现在,安装了证书,但是当您通过https访问任何子域名(例如:hxxps://subdomainx.domain.com)时,它指向 /home/DOMAIN/public_html/index.php 我们需要通过https hxxps://subdomainx.domain.com访问子域名 它指向的目录是相同的http: / home / DOMAIN / public_html / subdomainx 我们的供应商告诉我们,这是不可能的,目前的行为是正确的,为了达到这个目标,我们需要用htaccess来做到这一点。 我已经尝试了一些东西,包括这个解决scheme,这似乎是我所需要的: https ://stackoverflow.com/questions/5365612/advice-on-configuring-htaccess-file-to-redirect-http-subdomain- 到HTTPS-equival 但不能得到它的工作。 有小费吗? 谢谢。 补充:服务器是Apache。

带有UTF-8重音,多视图,.htaccess的Mod_rewrite

问题:使用Mod_rewrite,multiview和Apacheconfiguration 简介:该网站是法语,我有问题与unicode编码和mod_rewrite内的PHP无线多视图 旧服务器没有正确处理utf8(在PHP之间的某处,阿帕奇国防部重写或MySQL) 更新服务器到Ubuntu 11.04,这个过程是破坏性的 在var / www /(该网站主要是2个文件index.php&static.php)中丢失了所有文件 丢失了具体的.Htaccess文件 丢失了MySQL dbs 丢失旧的apache.conf 到目前为止,我做了什么: 什么工作: 设置GNutls for SSL,Listen 443 => port.conf 在一个文件中创build了2个虚拟主机:80和443 => website.conf 使用mod_rewriteredirect实施SSL =>redirect:80至:443 尝试设置utf-8无处不在。设置字符集和整理,db连接,mb_settings,名称utf-8和utf8_unicode_ci,无处不在(php,mysql,apache) 一定要服务文件为UTF-8我启用多视图 改名为index.php.utf8.fr和static.php.utf8.fr 启用多视图后,URL中的多字节口音将起作用 SSL TLS 1.0 什么不工作: 启用多视图后,mod_rewrite仅适用于我的一个重写过程 随着multiview禁用,我松散的访问文档的根目录为“禁止” 与多视图禁用,我松动多字节(单字符重音) Apache默认服务器已满设置。 (我可以安全地删除?) 这些是我的configuration文件到目前为止 :80个Vhost文件(这个工作可以用来强制redirect到https) RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} LanguagePriority fr :443 Vhost文件(GnuTls正在工作) DocumentRoot /var/www/x […]

如何在PHP和Apache中启动服务器用户身份validation?

我有一个生产服务器,用于在授予访问权限之前对用户进行身份validation。 我安装了一台新机器,并从旧服务器复制文件。 现在,我可以访问页面,但它不要求用户名和密码。 当我检查$_SERVER['PHP_AUTH_USER']是什么都不返回。 是在服务器上激活它的一种方法,或者我错过了任何文件,而从旧服务器复制它?

用htaccess访问目录会导致500错误

我在Windows机器上安装了Xamp服务器。 我已将follwing .htaccess文件放在一个目录中: # Original # If you modify this file then change the above line to: # Modified <IfModule mod_rewrite.c> RewriteEngine On # Certain hosts may require the following line. # If vanilla is in a subfolder then you need to specify it after the /. # (ex. You put Vanilla in /forum so […]

.htaccess重写规则不工作(CodeIgniter)

这是我想要做的:我使用的是CodeIgniter,所以所有的URL都是http://example.com/index.php/controller/function 。 不过,我写的脚本本质上是一个带有一些内置统计函数的优化链接缩写,所以我希望所有的URL都是http://example.com/link的forms。 不过,我还希望在http://example.com/admin/上提供脚本的pipe理面板。 我调整了CodeIgniter的“remove index.php from URLs”example .htaccess来适应我的情况,它在我的本地主机(EasyPHP 5.3.9)上正常工作,但是当我把它上传到生产服务器(HostGator)时,所有的pipe理面板的请求正在像普通链接一样处理,并传递给链接控制器( index.php/redirection/link )而不是pipe理控制器( index.php/admin )。 这是我的.htaccess: <IfModule mod_rewrite.c> RewriteEngine On # Removes access to the system folder by users. # Additionally this will allow you to create a System.php controller, # previously this would not have been possible. # 'system' can be replaced if you have […]

在Joomla的htaccess Mod_Rewrite

Joomla 1.5的URL结构在版本2.5中改变了。 之前是: http://example.com/index.php?option=com_content&task=view&id=587&Itemid=73 现在是: http://example.com/index.php?option=com_content&view=article&id=587&Itemid=114 *请注意ID和itemid数字基于页面更改,而所有页面有一个ID不是都在URL中具有的Itemid。 虽然我们更新了数据库中的所有链接,但很多人还是有旧的链接结构,所以我们要编辑htaccess文件,所以如果有人进入旧的结构,它会转向正确的结构。 简单地说,在url中input的任何URL与task = view都应该replace为view = article。 有没有人知道一个简单的方法来做到这一点在htaccess?

.htaccess将完整的URL传递到其他PHP链接为$ _GET

从.htacces文件,如何通过/redirect完整的URL到另一个URL作为GETvariables? 喜欢: http://www.test.com/foo/bar.asp 将被redirect到: http://www.newsite.com/?url=http://www.test.com/foo/bar.asp 与完整的url与域 。 我试过了: RewriteEngine on RedirectMatch 301 ^/(.*)\.asp http://www.newsite.com/?url=%{REQUEST_URI} 但它正在出去,如: http://www.newsite.com/?url=?%{REQUEST_URI}