Articles of 重写

Joomla URL重写在Nginx中自动运行

这是驱使我坚果,我不明白这是如何工作自动。 我有nginx作为我的networking服务器,我已经安装了URL重写的Joomla从URL删除index.php 。 之前,当我使用Apache时,必须使用RewriteEngine On启用.htaccess才能使其工作。 但对于Nginx,当启用“使用URL重写”时,它会自动运行。 我只使用将php文件传递给php-fpm的Nginx。 就这样。 我没有添加任何特殊的重写规则,而不是Joomla文档中给出的。 我不明白“启用URL重写”是如何自动启用的,因为Nginx没有.htaccess。 关于这个主题的Joomla文档没有帮助。 它在第二步说 启用使用Apache mod_rewrite / URL重写选项并保存:此选项使用Apache mod_rewrite函数来消除URL的“index.php”部分。 ….. 如果此选项导致错误,请参阅如何检查您的服务器上是否启用了mod重写。 如果未启用,并且您有权访问文件apache / conf / httpd.conf,请打开该文件并检查LoadModule行rewrite_module modules / mod_rewrite.so是否未注释。 如有必要,取消注释该行并重新启动Apache Web服务器。 不知道为什么这是在Nginxconfiguration中添加的,因为在Nginx中没有mod_rewrite。 Joomla后端的URL重写如下: 使用URL重写select使用服务器的重写引擎来捕获满足特定条件的URL,并按照指示重写它们。 适用于IIS 7和Apache。 仅限Apache用户! 激活之前,将htaccess.txt重命名为.htaccess。 将web.config.txt重命名为web.config,然后在激活之前安装IIS URL重写模块。 它没有提到Nginx,但仍然有效。 我在这里挠着脑袋。 有人能告诉我Joomla的index.php如何轻松地在Nginx中删除? 这是我的Nginx Vhostconfiguration: server { listen 80; server_name example.com; root /var/www/example/public_html; index index.php index.html index.htm […]

Nginx重写URL的一部分

我试图从URL的选项IDredirect到URL的选项URL_key我已经分配。 我有两个列ID与ID我想replace和URL_key作为替代。 11337酒吧11419餐厅11399咖啡厅15477绘画 我现在有这些url: ifab.ru/art/kartiny/location/11399/style/15477 我想redirect到: ifab.ru/art/kartiny/location/cafe/style/painting 你可以说我可以把网站上的所有url都replace成replaceurl,但是它们是自动生成的,而且每个url的组合可能都不一样,所以我想抓住这个ID并把它改写成URL_key。 任何想法和解决scheme,赞赏。 我们在nginx上运行我们的服务器,没有apache。

NginX重写和绝对资源path

在我的域名上,我有一个Meteor应用程序的子域 http://meteor.example.com/ 在此之下,我想个人应用程序,每个应用程序的URI。 说meteor应用聊天应该有这个url: http://meteor.example.com/chat/ 这是我的configuration: location ~ /chat/(.*) { proxy_pass http://127.0.0.1:4000/$1; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header X-Forwarded-For $remote_addr; if ($uri != /snake_meteor/) { expires 30d; } } 我按照这个指南来configuration它。 现在,这部分工作。 它将请求传递给应用程序,并返回页面的正确的HTML,但是随后出现问题。 返回的HTML引用资源文件,如JS,CSS和图像。 HTML中的引用不幸的是在表单上 <script src="/somescript.js"></script> 所以它的要求 http://meteor.example.com/somescript.js 绝对path… 在应用程序中更改它们并不是一个真正的select。 也不能将资源放在域的根目录下。 有什么我可以在Nginxconfiguration中做到这一点工作? 或者我有其他方式做这个,像另一个子域的水平? 编辑:我的一个朋友build议检查参考头。 它部分地工作。 一些文件被提取,但build立一个websocket和其他一些东西失败。 我为此添加的configuration是 location / { if ($http_referer […]

Nginx的如何运行shell脚本通过lua模块的页面加载执行,然后服务目录列表?

所以我有一个bash脚本,我想执行/运行在url的每个“页面加载”,以便它将修改(创build符号链接)到我想要服务器然后服务的/public/html/文件夹。 问题是我想出了如何做一个或其他不是两个。 我可以用nginx root /public/html/等来显示目录,或者我可以通过使用而不是root /public/html/来运行脚本: content_by_lua("/myscript.sh")'; 但是,如果我使用lua的内容,脚本会运行并创build我在/public/html里面所需要的内容,但Nginx会显示一个空白屏幕。 我想要一个方法来让nginx在使用content_by_lua运行myscript.sh后实际显示/public/html的目录列表。 我刚刚开始使用nginx是因为这个任务,并且很难做到这一点,我search了一下,但不是一个简单的问题,短语的谷歌或这里。

用POST重写请求到nginx的GET

我有一个后端服务器,由于各种原因,只处理GET请求。 这个服务器位于nginx代理的后面(即,所有的访问都通过nginx完成,nginx通过proxy_pass代理到后端)。 是否有可能使nginx重写POST请求到GET请求,即使POST /foo身体内容typesapplication/x-www-form-urlencoded和body foo=bar将被代理GET /foo?foo=bar ?

Postfix基于域重写收件人

我正在寻找一个后缀configuration来创build基于收件人域名的收件人重写规则,包括捕获所有在“不重写”列表中找不到的域。 例如: [email protected] ,不重写和交付给example.com的MX [email protected] ,重写为[email protected] <user>@<domain> ,重写为<user>@spam.example.com 理想将是不应该通过Postfix重写的域列表。 现在我使用一个没有例外的设置,所以一切都被重写了: recipient_canonical_maps = static:@spam.example.com

即使在非SSL的网站上,Nginx也总是重写为ssl

我有一个页面example.com,其中有SSL证书设置,一切工作正常。 这里是configuration的ssl部分: server { listen 80 default_server; server_name www.example.com example.com; return 301 https://$server_name$request_uri; } server { listen 443 default_server; server_name example.com www.example.com; # strenghen ssl security ssl_certificate /some/ssl/files.crt; ssl_certificate_key /some/ssl/files.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4"; ssl_dhparam /etc/ssl/certs/dhparam.pem; # Add headers to serve security related headers add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; […]

如果存在,Nginx将提供纯文件,否则将提供/index.php

我希望Nginx能够自己处理任何对静态文件的请求,但是如果文件不存在,那么可以使用index.php来处理这一切 目前我的configuration看起来像这样, server { listen 80; listen [::]:80; root /home/www/example.com/htdocs; index index.php; server_name www.example.com; location ~* ^[^\?\&]+\.(html|jpg|jpeg|json|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|svg|woff|ttf)$ { # First attempt to serve request as file, then # as directory, then fall back to index.php try_files $uri $uri/ /index.php; #try_files /favicon.ico =404; } location / { add_header X-Is-PHP true; try_files /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # […]

nginx子目录通配符重写

我已经在我的nginx服务器上build立了一个服务器模块,例如域testsite.com 。 我希望能够将独立的WordPress安装安装到根文件夹的直接子文件夹中,例如/var/www/html/testsite.com/ childfolder1 ,/var/ www / html / testsite.com / childfolder2等,所以他们可以通过testsite.com/ childfolder1 ,testsite.com/ childfolder2等访问 。 手动创buildredirect的方法是像这样插入它: location /childfolder1 { index index.php; try_files $uri $uri/ /childfolder1/index.php?$args; } 并重复每个网站来。 使用location /只覆盖根目录。 有没有办法创build一个(正则expression式?)通配符规则,说:“对于每个直接子目录,应用这个try_files命令”(这显然总是相同的WordPress,只是文件夹名称更改)? location /*anydirectsubdirectory* { index index.php; try_files $uri $uri/ /*anydirectsubdirectory*/index.php?$args; }

PHP的路由URL到index.php nginx

我正在运行一个nginx / php5.6-fpm服务器,我有以下几点 server { listen 10080; listen [::]:10080; root /home/vagrant/app; index index.php; server_name mia-dev.dev; port_in_redirect on; rewrite ^/static/(.*)$ /dist/static/$1 permanent; location / { try_files $uri $uri/ /index.php?$query_string; } # load the index page on 404 error_page 404 /index.php; # don't log requests to favicon.ico location = /favicon.ico { log_not_found off; access_log off; } # […]