如果我写: <?php echo "SCRIPT_NAME: ".@$_SERVER['SCRIPT_NAME']."<br />"; ?> SCRIPT_NAME:/index.php 上面的行显示。 我正在使用这些重写行 RewriteCond %{SCRIPT_NAME} !^/index\.php$ RewriteRule .* http://example.com/404 [L] 我检查过: http://example.com/foo http://example.com/bar http://example.com/hdhd RewriteCond匹配,然后我redirect到404 [03/Aug/2013:13:07:48 +0200] [example.com/sid#23c3710][rid#263afe8/initial] (4) [perdir /var/www/vhosts/example.com/httpdocs/] RewriteCond: input='' pattern='!^/index\\.php$' => matched [03/Aug/2013:13:07:48 +0200] [example.com/sid#23c3710][rid#263afe8/initial] (2) [perdir /var/www/vhosts/example.com/httpdocs/] rewrite '404' -> 'http://example.com/404' [03/Aug/2013:13:07:48 +0200] [example.com/sid#23c3710][rid#263afe8/initial] (2) [perdir /var/www/vhosts/example.com/httpdocs/] implicitly forcing redirect (rc=302) with http://example.com/404 […]
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !\.php$ RewriteRule ^(.*)/(.*)/(.*)$ $1.php?Action=$2&id=$3 RewriteRule ^(.*)/(.*)$ $1.php?Action=$2 RewriteRule ^(.*)$ $1.php 这是我的.htaccess 。 但只有第一个RewriteRule作品。 如果我评论其他规则,其他人就会很好地工作,但是他们不能一起工作。 我想要的是具有多个参数的干净的URL。 我没有任何关于这个问题的线索。 我GOOGLE了很多,我发现的所有信息都和我的代码一样。
我想让nginx重写任何http://api.example.org/xyz请求,在幕后调用example.org/api/xyz 。 棘手的部分是我使用的是CodeIgniter,而不是在/xyz/index.php中加载一个php脚本,我需要它用XYZ控制器引用CodeIgniter的/index.php。 现在我把它设置成这样: if ($host = "api.example.org") { rewrite ^(.*)$ http://example.org/api$1 permanent; } …但是会导致浏览器中出现明显的redirect。 我想重写是无缝的/在幕后发生。 所以我试了一下: if ($host = "api.example.org") { rewrite ^(.*)$ /api$1 last; } 但是,这给了我一个“没有input文件指定”的错误。 :(有没有人尝试在nginx之前重写一个子域到codeigniter控制器? 谢谢!
像一个URI /一个部分/一些部位/另一部分/后部分/?some_param = SOME_VALUE 我怎么去除一切到最后一部分的参数,并最终重写它看起来像 /index.php?id=last-part&some_param=some_value ?。 我尝试了各种各样的魔法,但最接近的是去除了问号。
我有一个Web应用程序位于/ subdir1 / subdir2 /我想简化为用户通过添加一个子域sub.domain.com,但它保持循环。 我试图添加额外的规则,以防止它,但没有喜悦。 所以会发生什么是http://sub.domain.com/subdir1/subdir2/subdir1/subdir2/subdir1/subdir2/subdir1/subdir2/subdir1/subdir2/subdir1/subdir2/ 我在web.config中的规则: <rule name="subdomain" stopProcessing="true"> <match url="^(?!sub/)(.*)" /> <conditions> <add input="{HTTP_HOST}" pattern="sub.domain.com/subdir1/subdir2/" negate="true" /> <add input="{HTTP_HOST}" pattern="sub.domain.com" /> </conditions> <action type="Rewrite" url="subdir1/subdir2/" appendQueryString="true" /> </rule> 有任何想法吗? 编辑:所以我真的想做的是让用户更容易。 现在他们必须inputwww.domain.com/subdir1/subdir2/来访问产品的login页面。 我想要做的是创build一个单独的子域,将重写到上面的链接。 而不是input长的url只需要去sub.domain.com,它会redirect或重写到www.domain.com/subdir1/subdir2/的位置。 我希望能让我的愿望更清楚些。 谢谢!
我们从$_SERVER['REQUEST_URI']获取信息不是从$_GET或$_POST 。 我想定义$request_uri来改变/example /module/controller/action 不redirect。 我尝试了代码打击这样做,但它不工作。 location /example { rewrite /module/controller/action; }
我正在尝试创build一个mod重写规则来正确地更改现有的url结构,如下所示: 旧:somesite.com/scripts/data/database.cgi?ArticleID=29154&report=SingleArticle&file=Data 进入如下所示的东西: 新:somesite.com/oldarticle/id29154.htm 我所需要的基本上是采取ArticleID并将其插入到新的url结构。 我提出的是不工作,但我知道我很接近: RewriteEngine On RewriteRule ^(.*)/database\.cgi\?ArticleID=([0-9]+)&report=SingleArticle&file=Data$ /oldarticle/id$1.htm [R=301,NC,L] # Permanent Move 我已经尝试了上面的许多变体,并且可能在初始string中缺less一些需要重写的东西。 任何帮助/build议将不胜感激!
CentOS 6.4 64位 Apache 2.4.6 PHP-FPM 5.5.4 从根加载的主页罚款http://csillamvilag.com 但所有其他页面返回404(CMS是WordPress)。 我也能够访问和login到WordPress的后端。 除了主页以外的所有WordPress页面都没有工作(全部返回404),例如http://csillamvilag.com/csillamtetovalas/csillamtetovalas-tanfolyamok/ http://csillamvilag.com/viszonteladok/ http://www.csillamvilag.com/forumok/ 没有一个OpenCart页面正在工作(全部返回404) 例如http://www.csillamvilag.com/shop/hu/ 这个问题似乎与URL重写… 如果我们试图直接或通过丑陋的URL访问文件,似乎或多或less ,例如http://csillamvilag.com/shop/index.php?route=product/product&product_id=231 但是,如果我们尝试“漂亮的url”或“SEOurl”,那么它不会, 例如http://www.csillamvilag.com/shop/hu/halvany-lila-strasszko-3mm (这个“漂亮的URL”对应于上面丑陋URL示例的相同页面) 这表示Apache中的URL重写问题。 影响WordPress和/home/shop/.htaccess的影响OpenCart的/home/.htaccess中的重写规则似乎没有问题。 例如WordPress / root .htaccess是: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Apache以用户apache的身份运行。 所有相关的WordPress和OpenCart文件都由用户apache拥有。 访问日志 127.0.0.1 – – [07 […]
我试图将这个htaccess规则转换为nginx: 阿帕奇 # Necessary to prevent problems when using a controller named "index" and having a root index.php # more here: http://httpd.apache.org/docs/2.2/content-negotiation.html Options -MultiViews # Activates URL rewriting (like myproject.com/controller/action/1/2/3) RewriteEngine On # Disallows others to look directly into /public/ folder Options -Indexes # When using the script within a sub-folder, put this path here, […]
为了将通常通过不同端口号(例如http://fooserver:18030 )访问的一些HTTPaudiostream映射到在标准端口80上可访问的URL地址(例如http://fooserver/capitalRadio ),我configuration了一些反向代理)。 它工作正常,但我有一个问题。 似乎有一些沉重的缓冲正在服务器上完成。 大约需要5分钟的时间才能开始在客户端上播放。 没有以前在IIS上重写URL的经验,有人能指出我可以调整哪些设置来减less播放延迟吗?