我有一个网站,其中一些url看起来像这样: /prefix/ID ,其中/prefix是静态的, ID是唯一的。 使用Nginx作为反向代理,我想只在/ID部分caching这些页面,省略前缀。 我可以configurationNginx,以便原始URL的请求被caching在缩短的URL? 我试过这个(我省略了一些不相关的部分),但显然这不是正确的解决scheme: http { map $request_uri $page_id { default $request_uri; ~^/prefix/(?<id>.+)$ $id; } location / { proxy_cache_key $page_id } }
我有这个URL重写规则 RewriteRule ^(send-your-request.*)$ / [NC,L,QSA,R=301] 它应该基本上只是从URL中删除“/发送你的请求”(即重写它的查询string参数从域即 http://example.com/send-your-request/?a_aid=rocketnews24&pname=just%20a%20test 被重写为: http://example.com/?a_aid=rocketnews24&pname=just%20a%20test 在这种情况下,它的工作,但如果我添加最后一个参数,它停止工作 http://example.com/send-your-request/?a_aid=rocketnews24&pname=just%20a%20test&plink=http%3A%2F%2Fradio-eva.jp%2Fshop%2Fproducts%2Fdetail.php%3Fproduct_id%3D82 任何人都可以告诉我一个更好的重写规则,可以处理所有的查询string参数? 编辑这里是我的其他规则,但我有第一个“L”,所以它应该停止处理权? RewriteRule ^(send-your-request.*)$ / [NC,QSA,R=301,L] Redirect 301 /products http://whiterabbitexpress.com/ RewriteRule ^index\.php$ – [L] RewriteCond %{QUERY_STRING} ^(.*)q=(.*)$ RewriteRule ^(.*)$ $1?%1s=%2 [L,R=301] RewriteRule ^catalogsearch/result/?$ / [NC,QSA,L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]
我有一个子域,something.site.com。 在我的主网站site.com/something,我想重写something.site.com,但保持urlsite.com/something完好无损。 那我能用nginx重写规则做些什么?
我正在尝试为Zimbra编写一个重写规则,这将允许我使用主机名来访问Zimbra桌面Web UI,而不是IP地址和端口。 默认的Zimbraurl如下所示: http://127.0.0.1:port/?at=long-encrypted-user-id http://127.0.0.1:port/zimbra/?at=long-encrypted-user-id http://127.0.0.1:port/desktop/login.jsp?at=long-encrypted-user-id 这是我到现在为止: server { server_name hostname; location / { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:port/; } } 这只会在后台用http://127.0.0.1:portreplacehttp://hostname ; 我卡住的地方是将?at=long-encrypted-user-id到URL中。 有人可以帮忙吗?
为了避免在一个文件夹中有太多的文件,我必须存储相当多的图像(比如1M),所以我打算把它们分解成与文件名相关的文件夹,例如: /images/1/5/3/153.png (我意识到有办法实现更均匀的分配,但我认为这将足以满足我们的需求) 但是,我希望这些可以从没有目录结构的URL访问,即: /images/153.png 这是否有可能在Nginx中完成,例如URL重写?
我正试图在Bluehost上build立一个Rails网站,而且我在path助手方面遇到了麻烦。 由于我不想猴子补丁Rails,我试图通过.htaccess来解决这个问题。 这是一个场景: 我在public_html/engradado www.engradado.com上托pipewww.engradado.com ,指向rails_apps/engradado/public 我正在通过这个public_html/.htaccess文件重写www.engradado.com指向www.engradado.com/engradado : # BlueHost.com # .htaccess main domain to subdirectory redirect # Copy and paste the following code into the .htaccess file # in the public_html folder of your hosting account # make the changes to the file according to the instructions. # Do not change this line. RewriteEngine […]
我有很多目录有相同的图像“_a.png”,如下所示: /data/images/{a,b,c,d} 因为这个,清漆caching多个副本。 现在我想重写一个url,像这样: if (req.url ~ "/_pty.png$") { set req.url="/images/a/_pty.png"; } 所以我重装清漆,但它不正确的工作! 例如。 我得到的url, http ://xx.com/images/c/_pty.png varnishlog我觉得这是不对的,代码上面没有任何效果! 如何设置?
我在Windows Server 2008 R2上运行使用IIS7的ASP.NET 4.0网站。 该网站在主域(〜/ site1,〜/ site2,〜/ site3等)下有许多Web应用程序。 每个Web应用程序都是同一网站源文件夹(D:\ Websites \ MySite)的一个实例,因此您可以通过以下任何URL访问同一个网站: www.mydomain.com www.mydomain.com/site1 www.mydomain.com/site2 www.mydomain.com/site3 每次返回同一个网站,但是根据调用哪个特定的URL,内容略有不同。 一切都一直工作好几个月,直到我被要求使用URL重写添加一些SEO优化。 我添加的每个URL重写规则都会产生以下错误: HTTP错误500.52 – URL重写模块错误。 页面无法显示,因为发生了内部服务器错误。 configuration错误:无法添加具有唯一键属性“名称”设置为“AddTrailingSlashRule1”types“规则”的重复收集条目 我已经阅读了围绕web.config文件中的<system.webServer> configSection的elswhere: <location path="." inheritInChildApplications="false"> 将解决这个问题。 但是,在停止显示错误消息的同时,它也会停止URL Rewrite规则在任何Web应用程序(〜/ site1,〜/ site2,〜/ site3)中的工作。 如何获取URL重写模块以使用Web应用程序? 谢谢你尽你所能的帮助。
我有一个专用于本地服务器(.dev)的域,以及一个将http://folder.dev/subfolder/这样的请求redirect到/htdocs/folder/subfolder的.htaccess文件。 除了一个小问题之外,它工作的很好。 当我启用了目录列表时,我可以正确地访问所有的文件夹,子文件夹和文件,除非当我点击Parent Directory链接,例如,应该导致http://folder.dev ,但redirect到http://folder.dev/folder/ ,最后抛出404 not found 。 同样,如果Parent Directory链接到http://folder.dev/subfolder/ ,它链接到http://folder.dev/folder/subfolder/ 。 下面是我的.htaccess的样子: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !(/$|\.) RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] RewriteCond %{ENV:REDIRECT_SUBDOMAIN} ="" RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9][-a-z0-9]+)\.dev\.?(:80)?$ [NC] RewriteCond %2 !^www|ftp|mail|pop3|localhost$ RewriteCond %{DOCUMENT_ROOT}/%2 -d RewriteRule ^(.*) %2/$1 [E=SUBDOMAIN:%2,L] RewriteRule ^ – [E=SUBDOMAIN:%{ENV:REDIRECT_SUBDOMAIN}] 除此之外,其他一切正常(例如文件中的相关链接等)
我在服务器上有很多的Vhost,我正在寻找一种方法来轻松地configurationUrl重写,而无需打开Putty,在SSH上连接和使用vim进行编辑。 是否有可能把重写规则放在我的www文件夹中的文件中,并每隔5-10分钟重新加载Nginx conf? 我不想要类似htaccess的行为。 只是把所有的rewrinting规则在我的项目的文件夹(SVN)。 在此先感谢(对不起,我的英语)!