Articles of mod rewrite

如何在Apache上启用mod_rewrite? 它看起来像启用,但它不工作

对不起,我不知道我在做什么,我需要你的帮助。 我有一个htaccess文件,做一些URL重写,但它不能在服务器上工作。 我不认为mod_rewrite被启用。 但没有注释掉,phpinfo()表示它是启用的模块之一。 我不知道该怎么办。 请帮忙! 从我的.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] 更新:我在http.conf中把这一行从none改为all: # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo […]

mod_rewrite代理多个服务器

我正在3台服务器上运行CentOS。 服务器A运行我的Apache Web服务器。 服务器B和C在不同的端口上运行其他服务器。 我试图让htt:// serverA / math /代理到htt:// serverB:8765 /但我得到的错误,我似乎无法修复。 这是我进入httpd.conf文件: RewriteEngine On RewriteRule ^math/(.*)$ http://serverB:8765/$1 [P] 我的日志中出现以下错误: [error] [client xx.xx.xx.xx] File does not exist: /var/www/html/math 如果我将httpd.conf更改为: RewriteEngine On RewriteRule ^/(.*)$ http://serverB:8765/$1 [P] 所有到服务器A的stream量都被正确地redirect到服务器B,所以我知道mod_rewrite和mod_proxy正在工作。 任何人都可以指向正确的方向吗? 谢谢。

.htaccess重写不正确的URL

我正在从一个旧的服务器迁移到一个新的网站,在这个过程中,我遇到了一些麻烦,Apache和mod_rewrite。 我有以下.htaccess文件: RewriteEngine on RewriteRule ^audio/(.*?)/.*?$ audio.php?id=$1 RewriteRule ^books/(.*?)/.*?$ books.php?id=$1 audio.php和books.php被调用,除了被捕获的variables没有被传递,所以在audio.php重写的情况下,我服务的是audio.php页面,但是$_GET是空的。 为了testing发生了什么,我添加了RewriteRule (.*) test.php?a=$1 ,其中test.php刚刚抛弃了$_GET当我做了$_GET['a']包含'test.php'。 在错误日志中没有任何东西显示出来,而且正确的文件被清楚地显示出来了,重写的工作基本上是正常的,而且configuration已经AllowOverride All我在做什么错了? 我想清楚,这个htaccess文件在旧的服务器上工作。

我如何做一个不区分大小写的mod_rewriteredirect到相同的URL(国防部的情况下)?

我正在使用区分大小写的Web应用程序来提供将要打印的几个URL,因此我们希望UsErs以不精确的方式input它们。 如何让mod_rewrite在[NC]redirect到正确的大小写URL,而不redirectURL并创build一个循环?

如何强制使用我的Django应用程序的一些URL的SSL?

我想确保对于我的网站的一些URL,SSL将被使用。 我已经看到了很多答案。 https://stackoverflow.com/questions/724968/force-redirect-to-ssl-for-all-pages-apart-from-one 所以我想我会用mod_rewrite。 我的问题是更多关于如何configuration虚拟主机通过HTTP和HTTPS运行我的Django应用程序没有问题。 我正在使用WSGI。 是否通过*:443和*:80复制configuration是一个问题? 我应该如何做最好的configuration? 谢谢。 雷米

Apache重写MOD启用,但得到错误

Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration Invalid command 'RewriteCond', perhaps misspelled or defined by a module not included in the server configuration 我跑了a2enmod rewrite ,它说“mod已启用” 现在我明白了 RewriteEngine not allowed here

如何在Ubuntu服务器上托pipe多个域(Hardy Heron)?

我想找出在我的Ubuntu服务器上托pipe多个域的最佳方式。 我已经尝试过多种select,但是我不能让所有的东西按照我想要的方式工作。 我希望能够添加域,而无需每次重新启动Apache。 我尝试使用mod_vhost_alias(见下文),但是将www.domain.com和domain.com映射到不同的文件夹。 我还需要能够使用mod_rewite来将domain.com/app/*的请求映射到domain.com/somescript.php 当前httpd.conf:UseCanonicalName Off VirtualDocumentRoot / var / www /%0 有什么想法吗?

使用mod_rewrite隐藏redirect

我正在使用mod_rewrite重写GET请求到一个特定的脚本。 我的目标是redirect请求: http://localhost/Work/dbUI/pageElements/Dialog/Contact.php?id=138750 至 http://localhost/Work/dbUI/pageElements/Dialog.php?dialog=Contact.php&id=138750 我在用着: RewriteEngine On RewriteLog "/var/log/rewrite" RewriteLogLevel 3 RewriteCond %{THE_REQUEST} /Work/dbUI/pageElements/Dialog/ RewriteCond %{QUERY_STRING} id=([^&?]*) RewriteRule (.*) http://localhost/Work/dbUI/pageElements/Dialog?dialog=Contact.php&id=%1 [R=302] 它工作得很好; 但是当我提出请求时,我得到了以下头文件(这是一个cURL例程的输出): * About to connect() to localhost port 80 (#0) * Trying 127.0.0.1… * connected * Connected to localhost (127.0.0.1) port 80 (#0) > GET /Work/dbUI/pageElements/Dialog/Contact.php?id=138750 HTTP/1.1 Host: localhost Accept: */* < […]

Apache重写到Nginx

我试图在我的Nginx服务器上安装buggenie。 不幸的是,它位于一个子目录(我无能为力),并使用Apache重写所有的URL。 当我从子目录中移动了所有东西的时候,我取得了一些成功,但不幸的是主目录中有一些东西需要它。 无论如何,我有它提供的.htaccess文件,我需要知道如何将重写转换为nginx重写。 我的configuration文件在这里: http://paste-bin.com/view/eb48c716 我认为主要的问题是RewriteBase … 抱歉join他们在一起,我目前无法添加超过1个url。

在Apache / htaccess压缩redirect。 怎么样?

当在htaccess中设置我的redirect时,我无法设置/组合各个域名,当他们都去相同的主页。 我可以做他们分开,但不是整齐/优雅。 如何重写第三段它是如何工作的? RewriteCond %{REQUEST_URI} ^/$ RewriteCond %{HTTP_HOST} ^website.de$ // works fine RewriteRule ^$ de/home [R=301,L] RewriteCond %{HTTP_HOST} ^website.fr$ // works fine RewriteRule ^$ fr/home [R=301,L] RewriteCond %{HTTP_HOST} ^website.com$ // doesnt work well RewriteCond %{HTTP_HOST} ^website.org$ // doesnt work well RewriteCond %{HTTP_HOST} ^website.net$ // doesnt work well RewriteRule ^$ en/home [R=301,L]