Articles of 重写

在htaccess中像foreach的东西?

我在这种情况下: url: domain/var1/var2/var3/…/varn 我想在以下url中更改该url: url: domain?v1=var1&v2=var2&v3=var3/…/&vn=varn 我发现这样: RewriteRule domain/([^/]+)/([^/]+)$ domain/index.php?v1=$1&v2=$2 [QSA,NC] 但是,正如你所看到的,我必须手动指定所有的variables…有没有办法自动做到这一点? 类似于:有一个/([^/]+)加v{N}=${N} ? 谢谢

Nginx的proxy_pass相对path

我目前有一个这样configuration的Nginx。 location /ui/ { proxy_pass http://ui:8888/; } 这个工程,但我有问题从服务中检索一些资源,例如,一些css样式引用/styles/style.css给404。我怎样才能告诉浏览器,基地址是/ ui /并不是 / ? 可能吗? 我也testing过这个configuration没有运气: location /ui/ { proxy_pass http://ui:8888/; proxy_redirect http://$host/ /ui/; proxy_set_header Host $host; }

在Nginx中合并redirect

我们正在使用Nginx,并希望减less我们拥有的“链接”redirect的数量。 所以,例如:URL A – http://www.sitename.co.uk/SHOPPING-CATEGORIES/product_name redirect到它的https版本(这是redirect1,将http更改为https) redirect的url然后redirect到相同的url,但都是小写的。 所以/ SHOPPING-CATEGORIES /成为/购物类别/(这是redirect2,将所有url更改为小写,因为它们区分大小写) redirect的url然后redirect到URL B – https://www.sitename.co.uk/category/product_name (这是redirect3删除string/购物类别,因为这不再使用任何url) 以上创build了三个单独的redirect,其中实际需要/需要的是 urlAredirect到urlB 这怎么能最好的实现呢? 非常感谢任何input

nginx单页js应用程序pushstate vs wordpress重写规则

我想添加:/客户端子文件夹包含骨干js应用程序(与pushstate)/pipe理子文件夹包含骨干js应用程序(有或没有pushstate) 当我在浏览器中打开我的http://example.dev/client时,它确实会打开单页面应用程序的index.html,但只要将/ gallery / 1 / date添加到url中,它就会打开wordpress 404页面,而不是pushstate。 这是我的nginx位置块: # {{ ansible_managed }} location ^~ /admin { #alias /var/www/project/admin/public/; try_files $uri $uri/ /index.html; rewrite ^/admin/(.+/)$ /admin/index.html last; } location ^~ /client { #alias /var/www/project/client/public/; try_files $uri $uri/ /index.html; rewrite ^/client/(.+/)$ /client/index.html last; } # Prevent PHP scripts from being executed inside the uploads folder. location […]

.htacces重写规则不起作用

我有一个非常简单的重写规则,但它不工作。 我有以下几点: #old see edits for newer versions RewriteCond %{HTTP_REFERER} ^localhost:8080(/|$) RewriteRule ^/downloads/.* /somePackage/index.php?id=5 [NC,C] RewriteRule ^/downloads /somePackage/index.php?id=2 [NC,L] 它似乎没有通过RewriteCond ,为什么是这样呢? 当我尝试这个: RewriteRule downloads/? /somePackage/index.php?id=2 [NC,L] 它似乎工作localhost:8080/downloads 但是当我尝试: RewriteRule downloads/.*/? /somePackage/index.php?id=5 [NC,L] 它不起作用,为什么这不起作用? 我应该怎么做呢? 编辑: 我这是目前的代码,只适用于localhost:8080/downloads和localhost:8080/downloads/但不是当我添加一些东西后斜线 RewriteRule downloads/somedownload/? /somePackage/index.php?id=5 [NC,L] RewriteRule downloads/? /somePackage/index.php?id=2 [NC,L] 编辑2: 这里是使用的.htaccess代码。 # Only the URLs /downloads and /downloads/ (with and […]

mod_rewrite和多个RewriteBases?

我如何设置重写引擎的重写基地 #access site via http://1.1.1.1/~sitename/ RewriteBase /~sitename/ 当它通过http://1.1.1.1/~sitename/访问并设置为 #access site http://www.sitname.com RewriteBase / 当它通过www.sitname.com访问? 我想要某种开关或条件。 因为现在,当我将RewriteBase设置为其中一个选项时,该网站在尝试访问其他url时不起作用。 编辑:新站点相同的问题….所以这是无法解决的?

正则expression式的URL在URL中?

我有我的.htaccess文件中的以下行,但它不断redirect到一个404错误。 RewriteRule ^ path1 /([a-zA-Z0-9 _-] +)/(。+)(/?)$ /file.php?variable1=$1&variable2=$2 [nc] 一个示例链接将是.. http://domain.com/path1/name23/http://domain2.com/stuff/is/here 我想把第二个URL转移到variables2。

未遵循.htaccess中mod_rewrite规则的顺序

我们正试图对某些url实施HTTPS,对其他网站实施HTTP。 我们也在重写url,所以所有的请求都通过我们的index.php。 这是我们的.htaccess文件。 # enable mod_rewrite RewriteEngine on # define the base url for accessing this folder RewriteBase / # Enforce http and https for certain pages RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !^/(en|fr)/(customer|checkout)(.*)$ [NC] RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} ^/(en|fr)/(customer|checkout)(.*)$ [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # rewrite all requests for file […]

有没有办法让iis 7中的虚拟目录指向另一个域?

让我们说我有两个子域名: http : //content.mydomain.com和http://app.mydomain.com 。 http://content.mydomain.com是指向一个不同的服务器比http://app.mydomain.com是。 有没有办法让http://app.domain/content url指向http://content.mydomain.com没有在浏览器中的url更改为子域? 我试图让这个工作在IIS 7/6和有问题。 任何build议将不胜感激!

使用IIS URL重写,如何重写foo.bar.com – > bar.com/myapp

我们的networking应用程序位于bar.com/myapp 我们将使用HTTP主机头来计算用户名 因此,需要使用IIS中的URL重写模块将foo.bar.com透明地重写为bar.com/myapp 但仍然需要能够访问www.bar.com并查看公司网站和webmail.bar.com等。 得到它的工作: 添加服务器范围的入站规则:匹配url: (.*) – 检查每个url 条件{HTTP_HOST} ^([^.]+)\.bar\.com – 必须是bar.com的子域名 条件{HTTP_HOST}不匹配模式: webmail\.|mail\. – 不要运行networking邮件。 或邮件。 操作重写: myapp/{R:1} – redirect到/ myapp /保留所有查询string数据