我习惯于使用Apache服务器,所以当启用mod_rewrite时,我可以创build一个htaccess文件并使用url重写。 这是我的htaccess文件: RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ – [NC,L] RewriteRule ^.*$ index.php [NC,L] 现在我已经build立了这个网站,使用这个URL重写模块,但我来了解到,它是一个微软的服务器。 我可以使用我的htaccess文件吗? 有什么我需要改变,以使其工作? 如何知道是否在Microsoft服务器上设置了URL重写? 更新:有一个免费的版本,我可以安装与htaccess文件的作品?
我有一个应用程序大部分仍在开发中,这就是为什么我需要阻止所有页面上的访问,但不是其中的两个。 假设我有一个.php所有的请求将被redirect到这里,除了b.php。 所以我认为应该有3条规则: 1st: when a.php and b.php are requested they should be visible to user, 2nd: if anything other than those two is requested, it should be redirected to a.php. 3rd: for external css,javascript and image files there should be an access rule 由于我没有太多的服务器pipe理经验,我相信我完全失去了:) 这是我试过的: RewriteBase / RewriteCond %{REQUEST_FILENAME} !^/b.php RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ a.php
是否有可能在URL参数规则中包含斜杠? 基本上我想要example.com/hello/world/去example.com?q=hello/world/。 任何例子,将不胜感激。 谢谢
我试图在我的Nginx服务器上安装buggenie。 不幸的是,它位于一个子目录(我无能为力),并使用Apache重写所有的URL。 当我从子目录中移动了所有东西的时候,我取得了一些成功,但不幸的是主目录中有一些东西需要它。 无论如何,我有它提供的.htaccess文件,我需要知道如何将重写转换为nginx重写。 我的configuration文件在这里: http://paste-bin.com/view/eb48c716 我认为主要的问题是RewriteBase … 抱歉join他们在一起,我目前无法添加超过1个url。
目前我正在使用 location /login { rewrite ^/login/$ /login.php last; rewrite ^/login$ /login.php last; } 重写www.example.com/login和www.example.com/login/。 我想知道这是否也可以在一个声明。 我试着rewrite ^/login(/)$ /login.php last; 但它没有工作。 另外我注意到,自从我开始使用重写,我的一些CSSpath被打破,因为我使用了相对path。 我将把它们全部转换成绝对path,但问自己在使用重写时是否还有更多的含义需要注意。 编辑: 这是我如何处理.php location ~ \.php$ { if (!-f $request_filename) { return 404; } fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; try_files $uri $uri/ /index.php; }
尝试了几个解决scheme后,我似乎无法得到这个工作。 我拥有一个.org,并有urls喜欢 http://mydomain.org/view/3242343 http://mydomain.org/login http://mydomain.org/page/5 我现在有了.com,并希望所有这些都能被正确使用到它们的.com等价物上: http://mydomain.com/view/3242343 http://mydomain.com/login http://mydomain.com/page/5 等等 我迄今为止所尝试的规则似乎是从.org获取任何URL,并将其发送到mydomain.com的根目录。 我需要什么htaccess规则? 谢谢,
我正在尝试学习如何使用nginx以及如何使用它的重写function Nginx似乎在做重写: 2012/03/27 16:30:26 [notice] 16216#0: *3 "foo.php" matches "/foo.php", client: 61.90.22.223, server: localhost, request: "GET /foo.php HTTP/1.1", host: "domain.com" 2012/03/27 16:30:26 [notice] 16216#0: *3 rewritten data: "img.php", args: "", client: 61.90.22.223, server: localhost, request: "GET /foo.php HTTP/1.1", host: "domain.com" 但在我的访问日志中,我得到以下内容: 61.90.22.223 – – [27/Mar/2012:16:26:54 +0000] "GET /foo.php HTTP/1.1" 404 31 "-" "Mozilla/5.0 (Windows NT […]
我在Apache2中有这个重写规则 RewriteRule country / usa [/] * $ / en / country / united-states [L,R = 301,NC] 我试图在nginx中构build一个等效的重写规则 服务器{ 重写^ country / usa [/] * $ / en / country / united-states last; #虚拟主机的剩余部分 } 但是这并没有工作:(任何想法如何做到这一点? 谢谢你的帮助
我有一些这样的htaccess: RewriteCond %{HTTP_HOST} !^foo RewriteCond %{HTTP_HOST} !^bar RewriteCond %{HTTP_HOST} !^some RewriteRule ^register,(.*)$ /register.html [R=301,L] RewriteRule ^offer,(.*)$ /offer.html [R=301,L] 它redirect我,如果我写http://foo.domain.com/register,one.html我只想在http://domain.com/register,one.html或http://www.domain.com/注册,one.html 哪里不对?
我知道这肯定已经被回答了一百万次,但是我似乎无法得到它的工作 我想将一个子域redirect到一个子目录。 我目前正在使用 server { server_name sub.domain.com; rewrite ^(.*) http://www.domain.com/sub-directory permanent; } 如果我导航到sub.domain.com我redirect到http://www.domain.com 编辑 这是我的完整configuration。 我已经改变了实际的域和子目录 server { server_name forum.domain.com; rewrite ^(.*) http://www.domain.com/forum permanent; } server { # Listen on port 80 as well as post 443 for SSL connections. listen xx.xxx.xxx.xxx:80; server_name domain.com www.domain.com; # Path to the files in which you wish to […]