小编kbi*_*rse的帖子

使用负正则表达式重写nginx URL?

我正在尝试将请求重定向到nginx中的https,除非它的格式为HOST/ANY_STRING_OF_CHARS/END_OF_URI,例如:

http://host.org/about#no redirect

http://host.org/users/sign_in#重定向到https://host.org/users/sign_in

这显然适用于Apache,但我不明白爆炸是如何工作的(忽略它是否真的起作用):

RewriteRule !/([a-z]+)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Run Code Online (Sandbox Code Playgroud)

如何在nginx重写规则中执行此操作?这不符合我的希望:

rewrite !/([a-z]+)$ https://$server_name$request_uri redirect;
Run Code Online (Sandbox Code Playgroud)

如果我有向后逻辑,这也不会重定向:

rewrite /([a-z]+)$ https://$server_name$request_uri redirect;
Run Code Online (Sandbox Code Playgroud)

请帮忙?

regex nginx

10
推荐指数
1
解决办法
4万
查看次数

如何在Rails中更改数据库模型和表的名称?

很多关于仅更改模型名称或将新模型映射到现有表格的内容,但没有关于同时重命名两者的内容.现在,我开始使用数据库表并在我的代码中使用查找/替换工作,但我很惊讶没有更好的东西,或者至少有人试过它并写了它.

migration refactoring model ruby-on-rails

6
推荐指数
1
解决办法
1940
查看次数

思考Sphinx索引在命令行上成功,但在Cron作业中失败

我承认我已经在Ubuntu上拼凑了一个大部分正在运行的制作设置,其中Capistrano来自官方文档(看起来过时且做了很多假设)和各种过时的博客文章.无论如何,最后一个烦人的挂断是当我手工完成索引时(并且在部署时我非常肯定),但是Cron无法工作.

这是我的crontab:

$ crontab -l
# m h  dom mon dow   command
* * * * * cd /var/www/app/current && /usr/local/bin/rake RAILS_ENV=production thinking_sphinx:index >> /var/www/app/current/log/cron.log 2>&1
Run Code Online (Sandbox Code Playgroud)

这是日志输出(这实际上每次调用出现3次):

Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
  * bin_path
  * searchd_binary_name
  * indexer_binary_name

For more information, read the documentation:
http://freelancing-god.github.com/ts/en/advanced_config.html
Run Code Online (Sandbox Code Playgroud)

这是当我手动运行相同的命令时(也可以在记录时运行):

$ cd /var/www/app/current && /usr/local/bin/rake RAILS_ENV=production thinking_sphinx:index
(in /var/www/app/releases/20100729042739)
Generating Configuration to /var/www/app/releases/20100729042739/config/production.sphinx.conf
Sphinx 0.9.9-release (r2117)
Copyright (c) 2001-2009, Andrew …
Run Code Online (Sandbox Code Playgroud)

cron capistrano ruby-on-rails thinking-sphinx

4
推荐指数
1
解决办法
1039
查看次数