我有这样的多个url。 http://domain.com/something/static/variable/ 但现在我想redirect上面的url http://domain.com/anything/static/variable/ 我试过了 location /something{ rewrite ^ http://domain.com/anything$request_uri? permanent; } 但是redirect到 http://domain.com/anything/something/static/variable/ 如何解决这个重写规则?
我应该如何将这个htaccess规则重写为nginx类的规则: RewriteCond%{REQUEST_URI}!^ /?puppy / index.php $ 重写规则。 /puppy/index.php
我有现在的请求,看起来像 https://smth.ru/smth/GET_DATA?p_DATA_TYPE=arg1#arg2&arg2=XXX 我知道这是非常不正确的,但我必须与它合作。 它和Apache一起工作。 现在我需要nginx作为这个请求的代理。 但它简单地丢弃了“#”后面的所有内容,而且在$ query_string之类的variables中找不到它 这就是为什么后端服务器只接收 https://smth.ru/smth/GET_DATA?p_DATA_TYPE=type 如何获得#后的参数或使nginx代理完整的请求? 我的服务器块看起来像 server { … location / { proxy_pass_header Authorization; proxy_pass_request_headers on; proxy_pass http://127.0.0.1:8080/$request_uri?$query_string; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } … } 通过代理作为 proxy_pass http://127.0.0.1:8080; 也没有效果。 试用套餐nginx.x86_64 0:1.6.2-23.el6.art然后更新到nginx.x86_64 0:1.8.0-1.el6.ngx – 相同的效果… UPD:似乎Apache使用整个请求,而nginx丢弃#后的所有内容。
假设我有一个通过HTTPS提供的网站,例如https://example.com/foo 。 考虑下面的.htaccess : RewriteBase / RewriteEngine On RewriteRule ^foo$ bar [R=301,L] 现在,当我访问https://example.com/foo ,它会通过HTTP而不是HTTPSredirect到http://example.com/bar 。 我怎样才能使它转到HTTPS而不是使用R标志的每个RewriteRule使用完整的scheme+主机? 也就是说,这会做我以后的事情: RewriteBase / RewriteEngine On RewriteRule ^foo$ https://example.com/bar [R=301,L] 但是,我的.htaccess文件包含许多这样的RewriteRule ,感觉应该有一种方式告诉Apache / mod_rewrite“重写为https://默认情况下”。 我真正想要的是告诉Apache网站使用的是HTTPS,类似于通过ServerName foo.ext声明主机名的ServerName foo.ext 。 那可能吗? 我猜这是堆栈溢出类似的问题: 如何说服Apache的原始客户端协议
我正在尝试从Apache迁移到Nginx。 我使用的是Nginx 1.8.1和PHP 5.6 Apache接受这样的URL: domain.com/site/index.php/something 并用参数/ something调用index.php脚本。 这是我的WordPress的工作原理,但还有其他脚本依赖。 例如,我可以这样做: domain.com/path/script.php/someparameter 我怎样才能在Nginx中工作? 编辑:我find了WordPress的解决scheme: location /blog/ { try_files $uri $uri/ /blog/index.php?$args; } 但是,对于所有脚本,通用解决scheme是什么?
我在Ubuntu 14.04上使用nginx(1.4.6-1ubuntu3.4)。 当有人访问一个页面,例如http://mymaindomain.com/page1 ,我想重写它包含www子域。 所以如果有人访问了以前的URL,重写的URL将是http://www.mymaindomain.com/page1 。 所以我添加了一个“服务器”指令: user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { … } server { server_name mymaindomain.com; rewrite ^ http://www.mymaindomain.com$request_uri permanent; } 到我的/etc/nginx/nginx.conf文件的末尾。 但重新启动我的服务器后,我得到的错误: 2016/11/04 22:12:33 [emerg] 1063#0: "server" directive is not allowed here in /etc/nginx/nginx.conf:75 什么是正确的方法来设置我的nginx服务器来正确地重写我的url?
我已经在我的apache服务器的/path上安装了一个php应用程序(dokuwiki),但是我希望在某些/ mydirpath上提供一些不同的文件(不同于dokuwiki的文件)。 目前,/ mydir只是在我的dokuwiki安装中popup一个不存在的页面,但是我希望在这里提供与dokuwiki内容非常不同的内容。 我在我的服务器上安装了dokuwiki在/ var / web / dokuwiki并且我的文件希望在/ var / www / mydir 有没有办法configurationApache服务我的文件,而不会干涉dokuwiki和viceversa? 目前的dokuwiki重写规则生活在.htaccess: ## Enable this to restrict editing to logged in users only # You should disable Indexes and MultiViews either here or in the # global config. Symlinks maybe needed for URL rewriting. Options -Indexes -MultiViews +FollowSymLinks # make […]
我想redirect www.foo.bar/baz/至www.foo.bar/qux 我有我的NGINXconfiguration下面的 rewrite ^/baz$ /qux permanent; 这将www.foo.bar/bazredirect到www.foo.bar/qux但将www.foo.bar/bazredirect到www.foo.bar 如果我更改configuration如下 rewrite ^/baz/$ /qux permanent; 要么 rewrite ^/baz[^/]$ /qux permanent; www.foo.bar/baz/redirect到www.foo.bar 我怎样才能使尾随/被尊重?
如果用户遗漏了url,我想重写url到www子域,即example.com/something.html到www.example.com/something.html 下面的configuration不起作用,用户仍然在example.com上。 有可能丢失一些非常简单的东西… <VirtualHost *:80> DocumentRoot /data/domains/example.com/www/public ServerName www.example.com ServerAlias example.com # ErrorDocument 404 /index.pl page_not_found # CustomLog /logs/apache/example.com/access_log combined # RedirectMatch 301 ^(.*)$ http://www.example.com/ <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^!example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] </IfModule>
如何将所有对www.mysite.com的请求redirect到www.mysite.com/index_main.php,然后将www.mysite.com/index_main.php重写为www.mysite.com