我已经打败了我的头对谷歌试图让这个工作,但我想我只是不完全理解重写引擎或我在正则expression式臭。 不过,这是我的场景。 我使用安装了URL Rewrite的IIS 7.5。 我有权访问web.config文件。 假设实际的服务器名称(本地和DNS)是authoritative.domain.subdomain.com。 它有一个cname.domain.subdomain.com的CNAME。 我想做一些事情: 强制https 将所有请求redirect到cname.domain.subdomain.com(甚至是部分/非FQDN,如authoritative,authoritative.domain或cname.domain) 如果请求是针对根站点的,则附加/子文件夹 尽可能地尝试一下,我可以让这些规则独立工作,但是当它们一起使用时,我不能让它们全部工作。 再次注意,这是IIS(我别无select),这样可能会使事情变得复杂。 谢谢你的帮助!
我有一个网站部署,使用kohana和URL重写,使URL更加宁静。 这工作正常。 我还将Moodle安装在同一台服务器的子目录中,并为此目录定义了一个子域。 所以Moodle安装在名为students的目录下,子域名为students.example.com。 这也工作正常。 我现在正在尝试安装我只需要在子域上的SSL证书。 我有一个Comodo通配符证书,所以它应该能够与子域一起工作。 当我使用https://example.com它工作正常,所以我可以看到SSL证书有效。 但是,当我尝试https://students.example.com它redirect到主站点。 http://students.example.com虽然工作正常。 适用于kohana重写规则的.htaccess文件是: # Use PHP5.4 Single php.ini as default AddHandler application/x-httpd-php54s .php # Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase / # Protect hidden files from being viewed <Files .*> Order Deny,Allow Deny From All </Files> # Protect application and system files from […]
我想弄清楚为什么下面的代码不起作用。 这是我的web.config文件的副本: <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <httpRedirect enabled="false" destination="https://" exactDestination="false" /> <rewrite> <rules> <rule name="server.child.domain.lcl redirect." patternSyntax="Wildcard" stopProcessing="true"> <match url="*server.child.domain.lcl/*" /> <action type="Redirect" url="https://server.child.org/application" /> </rule> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> <rewriteMaps> <rewriteMap name="StaticRedirects" /> </rewriteMaps> […]
我有一个nginx vHost主机: CMS在/ 在/store一个magento /store 事情运行良好,除了一件事情: 从URL中删除index.php。 目前下面的URL正在工作 example.com/store/index.php/my-funny-test-product.html and (as there are a few subshops in magento) example.com/store/index.php/city/my-funny-test-product.html 现在我必须build立一个redirect,以便index.php可以从URL中删除。 example.com/store/my-funny-test-product.html or example.com/store/city/my-funny-test-product.html 我用这个.htaccess来处理我的本地Apache RewriteEngine on RewriteBase /store/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule .* index.php [L] 基于这个我build立了以下重写 location /store { rewrite ^/store /store/index.php; } 现在example.com/store/my-funny-test-product.html作品,但CSS图像和类似的东西坏了! 我试图添加if (!-e $request_filename)来解决,但得到了一个nginx 40x错误。 我怎样才能实现工作重写example.com/store/my-funny-test-product.html和example.com/store/city/my-funny-test-product.html子文件夹/商店没有打破CSS&有没有index.php在URL中? […]
我正在尝试托pipe一个自定义页面,将其设置为我的服务器上的主页。 页面的真实path是example.com/start.html 。 但是,我不希望在我的主页中使用这个丑陋的URL,所以我试图让path是example.com/start/ 。 我的.htaccess文件内容是: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^start\/?$ start.html [NC,L] </IfModule> 这会使example.com/start正确redirect,但是example.com/start/会导致404错误(强调URL最末尾的斜线)。 我得到的错误是: The requested URL /start.html/ was not found on this server. 我相信我在RewriteRule中的正则expression式是正确的(它应该接受“开始”或“开始/”,所以我不确定问题是什么。 我将不胜感激这个问题的任何帮助。
我正在计划一个NVA服务器系统(Nginx-Varnish-Apache),请求按照这个顺序进行路由。 Apache将服务WordPress CMS或类似的。 我想知道在哪里应用额外的重写规则(如添加自定义重写手动configuration)。 应该重写在Nginx端还是Apache端? 哪个更容易实现,哪个更好? 还是应该重写在光油? 正如我所看到的,所有重写都可以在Apache中完成,因为Varnish将按原样提供这些重写的请求,从而在提供页面之前降低处理(?)的需求。 我是对的,还是在请求页面清除(从Apache获取页面)之前重写呢? 这要求服务器实际检查并对每个请求进行重写。 但是这样所有的重写将是“即时的”,而不需要在Varnish清除caching。 例1: 我有一个WordPress的多站点与子域安装(子站点去foo.domain.com , bar.domain.com , baz.domain.com等)。 多站点根站点应该驻留在www.domain.com ,但实际的内容可以在domain.com (不需要www )。 WordPress本身处理子网站的子域映射(数据库表切换),但是无www到www重写应该手动完成。 在哪里重写呢? 例2: 我在后台有一个特定的模板,有时可能会被重写,有时候不会。 让我们说它的www.domain.com/offer/12345/?available=0 ,有时我们可能要重写URLredirect到一个模板www.domain.com/offers有关不可用的数据。 这个重写会来来去去,取决于网站是否有不可用的报价情况的内容。 在Varnish之前或之后,这种重写会更好吗? (我知道这个redirect应该在网站的内部逻辑中完成以实现自动化,但是为了这个例子,我们假设它应该被服务器自己重写)。
我正在寻找写一个简单的重写规则,我基本上是想说以下 如果请求的URI是text / index.html(或test /),并且GeoIP组织等于“我的GeoIP值”,则server test / index2.html 我试了一些指令,没有什么是真正的工作,因为我所期望的。 我目前的设置是 map $geoip_org $redirectMe { default 0; 'My GeoIP Org Value' 1; } server{ …. location /test { try_files $uri index.html; expires -1; if ( $redirectMe ) { rewrite ^/test/index.html$ /test/test2.html break; } } …. } 我发现它无论是redirect还是redirect,不pipe我的IP组织如何,就像cachingredirect,我认为expires -1会被理清。 我也注意到,无论是否redirect,我都会收到HTTP 304请求。 有没有人有任何指针? 我认为这将是一件简单的事情。 我也试过不使用地图,并把比较放在地点,但这不起作用,使用服务器以外的地图将允许我稍后更容易地更改逻辑。 更新答案是,它实际上是工作,这只是caching不刷新时,我运行一个服务nginx重新加载。 解决的办法是使用服务nginx强制重装(或重启,虽然这是过度杀毒),它会wor
我有一个redirect的Apache服务器,我设置了约30个域名。 我想要所有的请求被redirect到主服务器,除了一个域。 基本上任何域到这个服务器被转发到www.maindomain.com; 但是,我想要domain234.com和www.domain234.com转发到https://www.site.com 我发现了这个回应,试了一下却没有成功: <VirtualHost _default_:80> RewriteCond %{HTTP_HOST} ^(.*)$ RewriteRule ^(.*)$ https://www.maindomain.com [R=permanent,L] </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName domain1.com ServerAlias www.domain1.com ServerAlias domain2.biz ServerAlias domain3.info RewriteEngine on RewriteCond (.*) https://site.foo.com [R=301,L] </VirtualHost> 任何人有我的build议来解决这个问题?
我需要像这样重写URL: example.com/demo/test/123/edit 至: example.com/demo/test.php?a=123&b=edit 它适用于这个重写规则: location /demo { rewrite ^/demo/(.*)/(.*)/(.*) /demo/$1.php?a=$2&b=$3 last; } 但URL可以是/ demo / test和/ demo / test / 123,所以重写规则不起作用。 我试过了: rewrite ^/demo/(.*)(?:/*)(.*)(?:/*)(.*) /demo/$1.php?a=$2&b=$3 last; 但没有运气。
我有包含caching清除string的URL。 我想重写这些URL而不使用caching清除string,然后将符合特定条件(如audio/video文件)的重写URL发送到PHP脚本。 例如 /style.1233333555.css => /style.css /video.3232474527.mp4 => /video.mp4 => /index.php 以下是我到目前为止: server { listen 80 default_server; server_name _; #force all traffic to be encrypted return 301 https://xyz.com$request_uri; } server { listen 443 ssl; server_name xyz.com; ssl on; ssl_session_timeout 5m; ssl_protocols TLSv1.1 TLSv1.2; ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; ssl_prefer_server_ciphers on; ssl_certificate /etc/nginx/ssl/xyz.com.crt; ssl_certificate_key /etc/nginx/ssl/xyz.com.key; root /srv/xyz.com; […]