Articles of 重写

面对nginx + tomcat上的应用程序redirect问题

我正在部署在tomcat上的应用程序面临一个奇怪的问题。 Nginx使用在tomcat之前从浏览器访问应用程序。 问题是,我在tomcat上部署了应用程序,然后在conf.d目录下的nginx上设置了虚拟主机。 [我创build的文件是virtual.conf。]下面是我用于相同的内容。 server { listen 81; server_name domain.com; error_log /var/log/nginx/domain-admin-error.log; location / { proxy_pass http://localhost:100; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } 现在的问题是,当我使用rewrite ^(.*) http://$server_name$1 permanent; 在服务器部分,请求被redirect到https://domain.com 。 我能够login到应用程序,并能够访问链接也。 我没有在这个主机文件中使用sslredirect,我不知道为什么会发生这种情况。 现在,当我从服务器部分删除redirect时,我可以访问应用程序:81,并能够login到应用程序,但是当我点击任何应用程序的链接,这将redirect到login页面。 我没有得到应用程序日志或tomcat日志中的任何日志。 如果这是nginx的redirect问题,请帮忙。

用于.htmlselect器的mod_rewrite

我们有一个网站,其url类似于www.example.com/about.smart.html (如果智能手机设备是基于useragent,则应用服务器上添加了“智能”select器) 如果用户更改了URL,我们需要将页面redirect到404,如下所示: www.example.com/about.abc.xyz.smart.html www.example.com/about.smart.abc.html 我试着用下面的规则,但是这个redirect到404只有1)而不是2) RewriteCond %{REQUEST_URI} !^(.*)(-)\.html$ RewriteRule (.*)\.(.*).smart.html$ – [R=404,L] 任何指针在这将有很大的帮助。

重写所有的.html扩展,并在Nginx中删除索引

如何从Nginx的urlstring中删除所有的.html扩展以及任何index.html的事件 http://www.mysite/index.html到http://www.mysite http://www.mysite/articles/index.html到http://www.mysite/articles http://www.mysite/contact.html到http://www.mysite/contact http://www.mysite/foo/bar/index.html到http://www.mysite/foo/bar 编辑:这是我的conf文件: 服务器{ listen 80; server_name staging.mysite.com; root /var/www/staging.mysite.com; index index.html index.htm; access_log /var/log/nginx/staging.mysite.com.log spiegle; #error_page 404 /404.html; #error_page 500 503 /500.html; rewrite ^(.*/)index\.html$ $1; rewrite ^(/.+)\.html$ $1; rewrite ^(.*/)index\.html$ $scheme://$host$1 permanent; rewrite ^(/.+)\.html$ $scheme://$host$1 permanent; location / { rewrite ^/about-us /about permanent rewrite ^/contact-us /contact permanent; try_files $uri.html $uri/ /index.html; […]

Lighttpd单个子域redirect/重写

这是最初的问题在stackoverflow ,但环顾四周,我得到了一个舒服的感觉,有人会知道答案。 我正在使用lighttpd,并希望有一个页面的urlpath显示为子域。 例如,我有以下url: http://test.com/blog/… 我想显示在浏览器的url为: http://blog.test.com/… 其他细节: blog.test.com已经是与test.com相同的服务器上的现有子域。 这是一个单独的Wordpress安装。 我们只是试图让一切下的一切,但保持子域的path。 什么是最好的方式去做这个?

Nginx的重写规则为301redirectfilename.asp到filename.php

我已经把我的文件名从filename.asp更改为filename.php,但现在我想301将所有来到filename.asp的请求redirect到它的等效filename.php 我已经尝试过这些变化,但他们只redirect到主页: if ($request_uri ~ .*.asp.*) { rewrite ^ http://$host? permanent; #rewrite ^/(.*)$ /$1.php permanent; } domain.com/folder/filename.asp 301redirect到domain.com/folder/filename.php 谢谢

将apache重写规则转换为nginx

大家好,我正在尝试创build一个UDID保护的Cydia Repo,但是我不能在nginx上使用它,因为nginx不使用.htaccess文件。 该文件确定重写规则,使其运行。 这里是回购的副本: https : //github.com/ic0nic/UDID-repo下面是.htaccess文件的副本。 RewriteEngine On RewriteBase /your_repo_folder/ RewriteRule ^(Release)$ release.php RewriteRule ^(Packages.*)$ package.php

nginx位置重写,但proxy_rewriteclosures

我试图用nginx代理请求到我的内部后端。 我的configuration如下所示: location /Shibboleth.sso { proxy_pass internal-backend; # ip proxy_redirect off; } 但是,我的redirect总是被重写..我的后端返回一个响应,如https://www.google.de/test ,我的浏览器接收到https://www.mydomain.de/test 如何让nginx转发响应?

nginx重写永久性重写的位置

我试图从mydomain.comredirect到www.mydomain.com ..但是,nginx正在重写位置标头为$主机。 server{ server_name mydomain.de; set $root /srv/www/mydomain.de; listen 8080; root $root; index index.html index.htm; location / { rewrite ^(.*) http://www.google.de$1 permanent; } add_header Cache-Control private; } server_tokens off; proxy_buffering on; proxy_buffer_size 8k; proxy_buffers 2048 8k; client_max_body_size 100M; client_body_buffer_size 100M; server_names_hash_max_size 1024; 这就是我的服务器configuration的样子。 但我没有redirect到谷歌,但坚持在redirect循环。 我在另一个服务器主机(www.mydomain.de)中有很多重写规则,但是它们似乎没有关系,因为这个虚拟主机甚至没有被使用。 Error.log的内容如下所示: 2012/10/24 17:26:26 [notice] 2244#0: *175 "^(.*)" matches "/", client: […]

在WordPress和Cherokee Web Server上使用虚拟域名

我试图configurationWordPress与切诺基Web服务器一起工作。 在WordPress中build立的多站点是yyy.com并使用“子域”。 因此,我有像aaa.yyy.com , bbb.yyy.com网站 – 他们都工作得很好。 但是,我有另一个完全不同的域名: abcde.com 。 在WordPress中,设置的子域名为abcde.yyy.com 。 当公共用户访问abcde.com ,无法正确地将其redirect到WordPress子域abcde.yyy.com 。 我如何设置切诺基正确的redirect虚拟域到WordPress? 这意味着,面向公众的域名将是abcde.com但WordPress会希望看到abcde.yyy.com正确返回特定网站的正确内容。 (我试过,它总是被redirect到这样的:“ http://yyy.com/wp-signup.php?new=abcde.com ”)

JBoss的URL重写

我试图通过在我的JBossconfiguration的standalone.xml中定义各种模式来重写URL。 这是现在的样子: <virtual-server name="default-host" enable-welcome-root="false"> <alias name="localhost"/> <alias name="example.com"/> <rewrite pattern="^/$" substitution="foo$1" flags="nocase"/> <rewrite pattern="^bar$" substitution="foo$1" flags="nocase"/> </virtual-server> 但是这些都没用! 如果有问题的话,我可以使用torquebox on / foo设置jruby应用程序。 我不介意在另一个文件中设置重写,如果更好的话。 我只是不知道如何。