Articles of 重写

IIS URL重写规则将子目录stream量redirect到https

我有一个网站,我已经写了一个URL重写规则,以引导所有site.comstream量到www.site.com。 工作正常。 现在我想将SSL添加到子目录中的应用程序。 我已经将SSL添加到网站,但是想要将所有去往http://www.site.com/application/的stream量redirect到https://www.site.com/application 以下是我想到的: <rule name="Redirect Supply Management System traffic to https" stopProcessing="true"> <match url="(.*)/supply-management-system/(.*)" /> <conditions> <add input="{HTTP_HOST}" pattern="(.*)/supply-management-system/(.*)" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}/{R:2}" appendQueryString="true" /> </rule> 如果我testing模式,他们似乎都可以,但是当我通过http导航到应用程序时,我不会redirect。 任何想法将是伟大的,谢谢!

Apache到Nginx的转换(新手)

我有一个PHP的Nginx Web服务器设置,我想在Nginx上移动,我想将这些.htaccess规则转换为nginx.conf文件: RewriteRule ^blog(|/)$ /data/core/site/blog.php RewriteRule ^blog/post(|/)$ /data/core/site/blogpost.php 到目前为止,这是我的: location /blog { rewrite ^(.*)$ /data/core/blog.php last; } 但是,如果我访问该页面( http://example.com/blog ),它给我的文件下载,我想它服务器的PHP和显示内容,我将如何解决这个问题? 完整的Nginxconfiguration:(在Windows上使用Winginx软件包): server { listen 127.0.0.1:80; server_name localhost; root home/localhost/public_html; index index.php; log_not_found off; #access_log logs/localhost-access.log; charset utf-8; location ~ /\. { deny all; } location = /favicon.ico { } location = /robots.txt { } location […]

HAProxy / Varnish:redirect一定比例的stream量

我正在尝试为两个不同版本的网页测量单独的统计信息。 所以我需要将我的networkingstream量的一定比例redirect到不同于所请求的页面的页面(即page_1的请求的20%转到page_1.1)。 在我看来,清漆可以在本地统计stream量或请求。 我想我可以让Apache后端计算请求,插入一个自定义头,然后让Varnish发送一个重新启动到客户端,如果后端响应包含该特定的头。 任何想法或build议? 干杯, 杰里米 编辑:我忘了提及在光油前面有一个HAProxy istance,所以我在想另一个好办法做到这一点可以是: 关于HAProxy: 计数page1的请求 如果count> 80,则插入自定义标题 如果count = 100重置计数器 在清漆上 如果自定义头在请求问题客户端重新启动与page1-> page1.1重写 不知道如何用ACL,gpc0和stick-tables来做到这一点。 我正在学习寻找解决scheme:-) 一如既往,想法或build议是受欢迎的

Nginx重写:删除? 在filename.php之后

这是我目前的nginx站点configuration: server { server_name DOMAIN; access_log /srv/www/DOMAIN/logs/access.log; error_log /srv/www/DOMAIN/logs/error.log; root /srv/www/DOMAIN/public_html; location / { if ($request_uri ~ ^/(.*)\.html$) { return 302 /$1; } try_files $uri $uri.html $uri/ @extensionless-php; index index.html index.htm index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1?$args; } […]

Nginx重写,重置重写或将扩展添加到特定的目录

这是我的nginx站点configuration: server { server_name DOMAIN.COM; access_log /srv/www/DOMAIN.COM/logs/access.log; error_log /srv/www/DOMAIN.COM/logs/error.log; root /srv/www/DOMAIN.COM/public_html; location / { if ($request_uri ~ ^/(.*)\.html$) { return 302 /$1; } try_files $uri $uri/ $uri.html $uri.php?$args; index index.html index.htm index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1$is_args$args; } […]

如何使用nginx中的if语句执行多个redirect

所以我的问题是一半SEO的一半技术:我有很多链接redirect,而不是一个接一个地做我的自我: 有没有办法写一个这样的重写规则(这是纯粹的小说,不能在nginx上使用) rewrite /america/(.*)/ http://www.example/nort-america/$1/ permanent; if 500 rewrite /america/(.*)/ http://www.example/south-america/$1/ permanent; 所以这个想法是redirect到一个特定的链接,如果redirect失败尝试其他链接。 这是可能的,而且这是SEO友好?

Nginx重写文件名为目录

我想重写一个文件名membership-list.html作为根域上的一个目录作为membership-list/ 。 我在我的configuration文件中有这个: location = ^/membership-list.html { rewrite ^/membership-list.html ^/membership-list/ redirect; } 我周围search,找不到任何有关从文件redirect到目录名称的信息。

Apache 2.4.27 mod_rewrite到cgi-bin失败

Oracle Linux 7 x64上的Apache 2.4.27。 我可以正确调用https://example.com/cgi-bin/helloworld.cgi 。 简单的Perl脚本返回“Hello,world via cgi-bin!” 我可以在https://example.com/helloworld.html正确调用静态内容 简单的HTML文件返回“Hello,world via html!” 我可以使用RewriteRule : RewriteRule "^/test" "/helloworld.html" 我看到“Hello,world via html!” 但是,我不能使用RewriteRule: RewriteRule "^/test" "/cgi-bin/helloworld.cgi" 这会导致400错误的请求。 那我怎么直接打电话呢? 如何在进入/cgi-bin时使我的RewriteRule工作? 这似乎是我的问题。 我尝试添加[L]和[L,PT]但没有任何帮助。

Nginx重写子文件夹到一个子域,并保持一切

我正在尝试重写url来处理以下情况,我想redirect几个特定的​​子文件夹到一些特定的子域,并保留子文件夹后的任何东西。 到目前为止我有: location / { rewrite ^/sub1/?(.*)$ https://sub1.example.com/$1 permanent; rewrite ^/sub2/?(.*)$ https://sub2.example.com/$1 permanent; rewrite ^/sub3/?(.*)$ https://sub3.example.com/$1 permanent; rewrite ^/sub4/?(.*)$ https://sub4.example.com/$1 permanent; } 这将处理example.com/sub1 example.com/sub1/ example.com/sub1/foobar 但不是example.com/sub1/page.php这是去example.com/sub1/page.php和404的原因它不存在。 我想要 example.com/sub1转到sub1.example.com example.com/sub1/转到sub1.example.com/ example.com/sub1/foobar转到sub1.example.com/foobar example.com/sub1/foo/bar/进入sub1.example.com/foo/bar/ example.com/sub1/page.php转到sub1.example.com/page.php 我在这里错过了什么? 我的正则expression式是生锈的吗? 编辑:这是我的整个configuration为该网站,万一它的一个问题与其他覆盖它的东西。 https://pastebin.com/sEka1Q0e

URL重写无限redirect问题

在我的.htaccess文件中,我有以下行: RewriteRule ^f/(.*)$ /blah.php?g=$1 我正在尝试使url如 example.com/f/three 被解释为 example.com/blah.php?g=three. 但是,像前者一样访问一个url会导致“最大内部redirect”错误。 我究竟做错了什么?