起初,这个规则是有效的: DirectoryIndex index.php ErrorDocument 403 /form.html RewriteCond %{REQUEST_URI} ^/index\.php$ RewriteCond %{REQUEST_METHOD} !POST RewriteRule . – [F,L] 这意味着http://example.com和http://example.com/index.php只能通过POST打开。 现在的问题 我添加了这个额外的规则集: RewriteCond %{REQUEST_URI} !^/index\.php$ RewriteRule . – [F,L] 现在,我再次发送POST到http://example.com但收到此错误: Forbidden You don't have permission to access / on this server. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle […]
我有IIS重写URL作为Apache Tomcat的反向代理。 example.com/app/redirect到example.com:8080/app/。 端口80redirect到同一台服务器上的端口8080。 如果我去example.com/app/,它按预期工作。 但是,如果我去example.com/app(没有结尾的斜杠),它会导致404错误。 我匹配入站规则的模式是^app/(.*) 。 然后该操作重写为URL http://127.0.0.1:8080/app/{R:1} 。 任何build议如何让这个工作没有斜线后面?
我有一个Web服务器与两个域和两个SSL,我看到一个关于如何configuration这个(SSL)和一切运作良好的video,但现在我的问题是,有一部分关于URL重写在哪里,如果我写像example.com它redirect到https://example.com和它的好,但现在如果我想写www.example.com更改为https://www.example.com但它说,无法访问该网站,但在SSL之前正在工作,我需要通过两种方式访问此网站 这是我的URL重写configuration 首先捕获 第二次捕获 我需要更改以使https://www.example.com再次可用?
我有一个简单的nginx重写在这里,使用永久标志,它工作正常。 location /area1/ { rewrite /area1/(.*)$ / permanent; } 但是,我想保留最初的url,这似乎从研究到只需要最后一个或中断标志。 location /area1/ { rewrite /area1/(.*)$ / break; } 在改变永久性(或最后 )之后,似乎完全忽略了redirect。 请有人可以演示一个工作的内部redirect,保留最初的url – 我知道这应该是简单的,但我已经尝试了大量的configuration变化,上述和似乎没有工作,redirect是更复杂的开始,但我已经减less到其基本forms只是为了得到正确的语法,我仍然失败… 在我引用的许多网页中,这是一个 – https://www.nginx.com/blog/creating-nginx-rewrite-rules/ server { listen 80; root /usr/share/nginx/html; access_log /var/log/nginx/root_host.access.log main; error_log /var/log/nginx/root_host.error.log; location /area1/ { rewrite /area1/(.*)$ / break; } if (!-e $request_filename) { rewrite /wp-admin$ $scheme://$host$uri/ permanent; rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) […]
是否有可能掩盖主机名与别名和variables? 例如: 我想调用http:// easyNameToRemember / path / to / file 代替: HTTP:// uglyServerName:8000 /的/真正/path/到/文件 基本上,“easyNameToRemember”将保存服务器名称,端口和静态APIpath。
我有以下NGINXconfiguration server { listen 80; server_name www.cakein.local; rewrite_log on; # removes trailing slashes (prevents SEO duplicate content issues) #if (!-d $request_filename) { # rewrite ^/(.+)/$ /$1 permanent; #} location /en { alias /home/sites/cakein/en/webroot; index index.php try_files $uri /index.php?$args; location ~ ^/en(.*)\.php { index index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_index index.php; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$1.php; […]
前提 在安装了最新Apache2的Ubuntu 16.04服务器上,我有不同的虚拟主机, 每个人都正确configuration(并使用Let's Encrypt进行保护): / etc / apache2 / sites-enabled / my.site.com-le-ssl.conf / etc / apache2 / sites-enabled / my.other.site.com-le-ssl.conf 指向下面的静态内容: /var/www/my.site.com/ /var/www/my.other.site.com/ 这工作正常 : 通过调用https://my.site.com/我看到/var/www/my.site.com/包含的静态网站。 然后,我安装了Tomcat 8.5.9并使用反向代理进行了保护 ,因此添加了以下内容: <VirtualHost *:443> . . . JKMount /* ajp13_worker . . . </VirtualHost> 到/ etc / apache2 / sites-enabled / my.site.com-le-ssl.conf 。 这也工作正常 : 通过调用https://my.site.com/现在我看到了Tomcat的家。 期望的目标 […]
我有以下的Nginxconfiguration: server { listen 80; location /test { rewrite /test(.*) /$1 break; proxy_pass "http://www.example.com/"; } } 这适用于主页,当input“ http:// localhost / test ”时,我得到http://www.example.com/的内容,URL仍然是“ http:// localhost / test ”。 很酷,但是当我点击网站中的一个链接时,说/more_examples我想链接被改写为: http:// localhost / test / more_examples 。 在实践中,我得到以下: http:// localhost / more_examples ,这显然不会工作。 这甚至有可能吗? 任何帮助将不胜感激。
我有一个运行在自定义CSM上的网站。 然而,随着它越来越大,我们不得不把它移到wordpress。 在旧CMS上,我们使用了与以下类似的文章的url结构: https://example.com/parent-category/child-category/7564-title-of-the-article https://example.com/parent-category https://example.com/parent-category/child-category 我们希望将所有请求redirect到这个结构的旧文章 https://example.com/title-of-the-article https://example.com/category/parent-category https://example.com/category/parent-category/child-category 这里的分类是wordpress slug 我在nginx中尝试了一些redirect规则,然而事实certificate我对于正则expression式并不擅长。 我无言以对 请帮我做。 我不知道该去哪里。 这将不胜感激。 更新:编辑原始的链接结构,以消除有关“类别”是一个静态的slu conf混乱。 不是这样。 有多个类别和子类别: https://example.com/review/app/734-title-of-the-post https://example.com/news/546-title-of-the-post https://example.com/blog/opinion/456-title-of-the-post
我有一个RewriteRule重写包含文件版本的文件的任何请求没有版本: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.+)\.[0-9a-f]{32}(\.[0-9a-z]{2,6})$ $1$2 [L] 这意味着只要文件styles.<version-id>.css被请求,就会被重写为styles.css 。 现在,如果要求文件的版本化版本,我怎样才能设置caching头文件,以便文件被caching更长的时间? 换句话说,如果文件styles.css被重新定义,它应该被caching24小时,而文件styles.<version-id>.css应该被caching365天。 我已经尝试使用此代码片段重写之前和之后使用FilesMatch设置caching: <FilesMatch ".+\.[0-9a-f]{32}\.[0-9a-z]{2,6}"> Header set Cache-Control "max-age=31536000, public" </FilesMatch> 但它不起作用。 也许它不匹配,因为文件名被重写。 我不知道。 我也尝试使用环境variables: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.+)\.[0-9a-f]{32}(\.[0-9a-z]{2,6})$ $1$2 [L,E=AutoVersion] Header set Cache-Control "max-age=31536000, public" env=AutoVersion 但是我也无法得到这个工作。 有什么方法可以根据原始请求设置重写请求的caching策略吗?