Articles of mod rewrite

HTTP到HTTPS重写不能在第一次工作

我所有,我有一个奇怪的问题redirect到运行Apache的Debian上的HTTPS。 当用户第一次访问http://subdomain.url.nl时,会报告一个未find的页面。 当用户访问https时,它可以工作。 然后用户closures浏览器,再次启动浏览器,并转到http(没有https),redirect突然工作。 我使用这个重写规则。 (*隐藏在这个职位的IP地址) <VirtualHost 10.*.*.*:80> RewriteEngine on RewriteCond %{SERVER_PORT} !^443$ ReWriteRule ^/(.*) https://%{HTTP_POST}/$1 [NC,R,L] </VirtualHost> 所以,只有用户第一次通过http访问该站点,redirect不起作用。 任何想法如何解决这个问题?

帮助一个mod重写规则

如果文件位于/wp-content/*目录中,只要它是.+\.(jpe?g|gif|png|js|css)$ ,否则抛出一个[F ] orbidden“。 我似乎无法围绕从哪里开始。 我可以用正则expression式,但我的改写技巧(显然)缺乏。

如何插入一个“index.php”到每个使用.htaccess的url?

例如:我的网站被这样调用: www.example.com/controller/method/parameter1/parameter2 现在,.htaccess需要重写这个URL到: www.example.com/index.php/controller/method/parameter1/parameter2 但问题是:如果是img , css或js目录,则不应该发生redirect。 我怎样才能做到这一点? 我只知道mod-rewrite引擎是我的朋友。

如何使用htaccess&apache重写/页面到/ xx / page?

想像一下三步跳跃的体育赛事,前两步完美到位,第三步跳入空中,永不回头,最终摔倒! 这就是这个问题归结为:) 第1 /somepage?ln=xx :当用户导航到/xx/somepage时,工作服务/somepage?ln=xx 。 # if user inputs nice urls /xx/somepage to serve page /someapge?ln=xx RewriteRule ^([az][az])/(.*) /$2?ln=$1 [L] 第二步:只有在给定语言的情况下才能进入主页/ xx / # if language xx given but no page given? then redirect to its home /xx/home RewriteRule ^([az][az])/?$ /$1/home [R=301,L] 第3步:碰撞 # if user inputs /somepage then redirect to default english: /en/somepage […]

将子文件夹从httpredirect到https

我怎么能redirect到https的子文件夹,例如http://example.com/vacation-rental/115到https://example.com/vacation-rental/115

如何在IIS Web服务器上mod_rewrite

正如我以前的服务器是一个Linux驱动的机器我有这段代码: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?path=$1 [NS,L] </IfModule> 这段代码将这样的信息放在URL中: http://www.example.com/nr1/nr2/nr3/ 进入一个这样的数组: array ( 0 => "nr1", 1 => "nr2", 2 => "nr3") 我的新服务器机器是基于Windows 2008(IIS)的服务器。 现在我想在我的新服务器上使用mod_rewrite mod。 总之我的问题是: 任何人都可以告诉我,或者链接到一个教程告诉我,如何安装/使用mod_rewrite国防部(或任何国防部做同样的事情),并将上面的代码转换成我可以在我的基于Windows的服务器上使用的格式。 我仍然使用PHP,而不是ASP.NET ,我知道很多人会说使用Apache或东西,但不幸的是需要使用IIS。 提前谢谢了!

在apache上的虚拟主机指向domain.com,domain.net,domain.org全部转到domain.com

目前所有的名称都指向同一个Web服务器文件夹,这是正确的。 也就是说,domain.net,domain.org等工作,而不redirect到主.com 如何访问.org和.net将浏览器redirect到domain.com? 这应该是基本的,但我无法弄清楚最好的办法。

Apache重写规则添加了2个超快的斜杠

我想在apache2.2中将所有的wwwredirect到非友好的301 它基本上工作,但是当我在浏览器中inputwww.test.net时,我被redirect到test.net//,我宁愿不用双斜线。 这是在我的VHOST: RewriteCond %{HTTP_HOST} ^www.test.net [NC] RewriteRule ^(.*)$ http://test.net/$1 [L,R=301] 编辑:它更糟糕: www.test.net/home在浏览器被redirect到test.net//home

为什么不这个.htaccess文件redirect正确?

我有一个Web应用程序与多个页面。 .htaccess文件将domain-name.com/之后的所有内容redirect到我的index.php文件中,该文件处理input并呈现相应的页面。 但是,我也有一些实际的目录下domain-name.com/需要从redirect除外。 例如,我的PHPMyAdmin目录(/ pma)。 一切工作正常,直到我添加行redirect报告/ [名称]索引页也。 现在,我的/ pma不会进入PMA目录,而是进入我的应用程序的index.php。 如果我使用/pma/index.php,它可以工作,但是为什么/ pma会停止使用那个新的重写规则。 注释报告的RewriteRule导致一切再次运作。 我无法弄清楚为什么。 谢谢你的帮助! .htaccess文件: RewriteEngine On # Redirect http to https (http://htaccesscheatsheet.com/#force-https) RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} # Ignore the following directories (don't remap to page engine) RewriteCond %{REQUEST_URI} !^\/(pma*|css) #Redirect all /reports/[report name] requests to index.php?page=reports/[report name] RewriteRule ^reports/([a-z0-9\-_]+)\/{0,1}$ index.php?page=reports/$1 [NC,QSA,L] #Redirect […]

如何确定是否安装了Apache的mod_rewrite

我在Suse机器上安装了Apache 2。 我已经通过它的configuration文件,检查哪些模块安装在Yast中,甚至尝试在.htaccess中写入重写规则,这是行不通的。 我似乎无法在任何地方findmod_rewrite。 我认为这意味着mod_rewrite没有安装? 我怎样才能确定?