我的httpd.conf文件中有一个Apache 301redirect,它将所有stream量redirect到一个单一的域以进行规范化处理。 我最近注意到这个redirect不会保留标题中的引用。 RFC2616似乎表明在redirect时保留引用者是可选的,并且实际上在HTTP和HTTPS之间穿越时build议使用引用者。 虽然,我发现其他问题 ,其中一个简单的Apache 301redirect保留引荐,这通常是默认的情况下。 什么是可能影响这种行为的其他因素,我可以用来保护引用者? 是基于Apache服务器版本和/或客户端浏览器设置的唯一因素(IE。在我的控制之外)? 我的redirect: ServerAlias www.example.com sub1.example.com ## Redirect all sub-domains to www RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com$1 [R=301,L] 关于上面的重写规则,我正在访问http://sub1.example.com 。 我现在只是简单地使用HTTP,直到我能弄明白为止。 我确定引用链接的方式并没有被结转,只能通过浏览器手动访问redirect的网站,并打开开发者工具。 我也确定引用不包含在PHP的$_SERVER全球接收页面上。 我可以确认只有1个redirect发生。 服务器端语言是PHP。 这是初始页面(sub1.example.com)的请求标题: GET / HTTP/1.1 Host: sub1.example.com Connection: keep-alive User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 […]
我有一个应用程序大部分仍在开发中,这就是为什么我需要阻止所有页面上的访问,但不是其中的两个。 假设我有一个.php所有的请求将被redirect到这里,除了b.php。 所以我认为应该有3条规则: 1st: when a.php and b.php are requested they should be visible to user, 2nd: if anything other than those two is requested, it should be redirected to a.php. 3rd: for external css,javascript and image files there should be an access rule 由于我没有太多的服务器pipe理经验,我相信我完全失去了:) 这是我试过的: RewriteBase / RewriteCond %{REQUEST_FILENAME} !^/b.php RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ a.php
我有products.php,我试图改变成/ europe-cell-phone /。 我做了一个重写规则来做到这一点: RewriteRule ^europe-cell-phone/$ products.php [L] 但是,我也需要301旧页面(products.php)到/ europe-cell-phone /。 我试图用以下规则来做到这一点: RewriteRule ^products.php$ http://www.eurobuzz.com/europe-cell-phone/ [R=301,L] 然而,当然,当我去products.php期待被redirect,我打了一个无限的redirect循环,有没有解决这个问题? 以前从未遇到过这个问题。
我有一个文件www.example.org.conf ,我想将httpredirect到https 。 问题是该文件不完全正确的工作。 <VirtualHost *:80> ServerName example.org ServerAlias www.example.org DocumentRoot "/var/www/example.org/www" CustomLog /var/www/example.org/www.access.log common ErrorLog /var/www/example.org/www.error.log RewriteEngine on RewriteCond %{SERVER_NAME} =example.org [OR] RewriteCond %{SERVER_NAME} =www.example.org RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] </VirtualHost> redirect实际上是从letsencrypt自动生成的,但是这是问题所在。 在http://www.example.org中键入将按照预期redirect到https://www.example.org 。 问题是当你inputhttp://example.org时 ,它将显示apache的默认页面,而不是redirect到https。 当我inputhttps://example.org或https://www.example.org (显示我想要的页面)时,我可以validationSSL conf是否正常工作。 所以我得出结论,问题在于mod_rewrite 。 但是,我不知道什么是错的。 事实上,我遵循相同结构的其他虚拟主机按预期工作。 请帮我弄清楚我的网站configuration有什么问题。 顺便说一句,我使用Debian的Apache2。
我需要一个.htaccess来显示这个URL: http://www.mysite.com/es/wp-content/plugins/mailpress/mp-includes/action.php?action=mail_link&add=123&lang=es 但实际上会提供这个url: http://www.mysite.com/wp-content/plugins/mailpress/mp-includes/action.php?action=mail_link&add=123&lang=es 请注意,action.php可以接收URL中的其他GET参数。 htaccess也必须能够发挥它们的作用。 这两个URL之间的唯一区别是将反映“lang”GET参数的“假”根目录。 是否有可能用.htaccess做这样的事情(我很确定这是可能的)? 任何人都有指示如何做到这一点? 谢谢! 编辑1:我忘了说重写规则应该只对“/ wp-content / plugins / mailpress / mp-includes /”中的“action.php”有效。 编辑2:我目前在我的.htaccess: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
这工作; 我没有麻烦, 但我想确定这是防弹的。 我想出了一个简单的.htaccessredirect ,但我不确定它是否安全。 你知道吗? <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^ goto /([az] +)/?$ / $ 1 / [R] </ IfModule>configuration 我认为,只要服务器configuration正确,文件自动处理authentication,那么它不应该是一个安全问题。 另外,因为重写规则只适用于字符az和一个斜杠我怀疑他们可以通过注入东西到目录跳转目录我认为…
我正在下面的错误在Apache日志 文件不存在:D:/ wamp / www / script / products,referer: http://localhost/script/products/category/product-123.html每当跟随url localhost / script / products / category / product-123。 html是通过这个重写规则来parsing的。RewriteRule ^ products /([〜A-Za-z0-9 – “] +)/([〜A-Za-z0-9 – ”。+)。html $ index.php? page_type = products&prod = $ 2 [L]。 脚本和规则工作正常,但我得到的错误在Apache错误日志。 我已经激活了RewriteLog,但在rewrite.log文件中没有显示出来。 它是空的。 请提前帮助和感谢。
我目前正在处理我的AWS网站的内容重复问题,以达到search引擎优化目的。 更具体地说,我试图为重复地址实现重写规则: 公共DNS(ec2-my.ip.address.compute-1.amazonaws.com/anywebpage) 弹性IP(my.ip.address / anywebpage) 到我的主域名http://mydomain.com/anywebpage 我已经应用了以下修正,只是似乎只是改写/ 301主页: RewriteEngine On RewriteCond %{HTTP_HOST} my.ip.address.compute-1.amazonaws.com RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L] 它似乎没有做的是适用重写规则的任何网页我访问重复的地址下。 例如,如果我访问my.ip.address.blabla.com/mywebpage,我应该redirect到http://www.mydomain.com/mywebpage 我在这里错过了一些关键的语法吗? 任何帮助赞赏。
我正在尝试将Apache的网站移动到iis 8.5 一切正常,但1规则failes我的网站正常运行 RewriteCond %{REQUEST_URI} !\.(js|css|jpg|jpeg|gif|png)$ [or] RewriteCond %{REQUEST_URI} apple-touch-icon\.png$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L,QSA] 有人可以把它翻译成IIS重写? 我find了一些例子来做到这一点 <rule name="Webasyst Controller" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{URL}" pattern="!\.(eot|ttf|woff|js|css|jpg|jpeg|gif|png)$" negate="true" /> <add input="{URL}" pattern="apple-touch-icon\.png$" negate="true" /> </conditions> <action type="Rewrite" […]
使用vhosts和letsencrypt证书运行Apache 2.4.7(Ubuntu 14.04)。 许多虚拟主机运行WordPress创build一个.htaccess文件。 我已经排除了这些.htaccess文件中的.well-known文件夹,但是定期更新WordPress或插件来擦除这些手动修改。 在每个虚拟主机下RewriteEngine off这个文件夹的RewriteEngine off会更好,但是这样做很困难,因为在<Location>指令下这样做是不被支持的。 从我所看到的<Directory>指令必须是特定的而不是相对的? 我有什么select? 鉴于我在Apache 2.4.7我可以活着添加RewriteOptions Inherit到每个虚拟主机configuration。 但是想避免为每个虚拟主机添加定制的configuration。