我在.htaccess中获得了以下代码: Options +FollowSymlinks RewriteBase /temp/test/ RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^about/(.*)/$ $1.php [L] RewriteRule ^(.*)/download/(.*)/(.*)/(.*)/downloadfile/$ file-download.php?product=$1&version=$2&os=$3&method=$4 [L] RewriteRule ^(.*)/download/(.*)/(.*)/(.*)/$ download-donate.php?product=$1&version=$2&os=$3&method=$4 [L] RewriteRule ^(.*)/download/(.*)/$ download.php?product=$1&version=$2 [L] RewriteRule ^subscribe/(.*)/$ subscribe-$1.php [L] RewriteRule ^subscribe/(.*)/(.*)/$ subscribe-$1.php?email=$2 [L] RewriteRule ^(.*)/screenshots/$ screenshots.php?product=$1 [L] RewriteRule ^(.*)/(.*)/$ products.php?product=$1&page=$2 [L] RewriteRule ^schedule-manager/$ products.php?product=schedule-manager&page=view [L] RewriteRule ^visual-command-line/$ products.php?product=visual-command-line&page=view [L] RewriteRule ^windows-hider/$ […]
我试图使用mod_rewrite和mod_proxy一起通过一个(假)子目录“foo”( http://example.com/foo )从不同的内部web服务器( http://webserver.internal.com/foo )提供内容)。 使用mod_proxy和ProxyPass指令我已经可以在/etc/apache2/mods-enabled/proxy.conf中使用这个configuration ProxyPass /foo http://webserver.internal.com/foo ProxyPassReverse /foo http://webserver.internal.com/foo 现在我有额外的要求来强制重写从http://example.com到https:// example.com的dynamic资源的所有请求,它们也是独立运行的,但不能与上面提到的ProxyPass规则一起使用。 看来代理configuration总是优先于重写规则。 就我的研究显示,在我的重写规则中使用mod_proxy应该像添加一样简单 RewriteCond%{REQUEST_URI} ^ / foo RewriteRule ^ / foo(。*) http://webserver.internal.com/foo $ 1 [P] 到我的重写规则和重写的URI将自动通过mod_proxy传递。 我打开了一个LogLevel为9的RewriteLog,但之后我无法看到^ / foo的匹配和下面的Proxy-RewriteRule的执行情况。 没有什么比预先代理,或任何提及的代理,甚至没有在RewriteLog中的错误条目。 我有我的apache2configuration中激活以下代理模块 proxy proxy_connect proxy_http 我试图用另一个例子来testing我的RewriteCondition – 这次匹配^ / foo并redirect到www.google.com RewriteCond %{REQUEST_URI} ^/foo RewriteRule ^(.*)$ http://www.google.com/ [R=302,L] 这是按预期工作的,在RewriteLog中有以下结果: RewriteCond:input ='/ foo'pattern ='^ / […]
我有一个网站从这个URL到达: http://www.mysite.com/cms/index.php 从这个目录提供服务: public_html/cms/index.php 在public_html我有这个.htaccess RewriteRule (.*) cms/$1 [L] 这让我到这样的网站: http://www.mysite.com/index.php 但是现在如果我引用“旧”地址,我想用redirect代码redirect到重写的地址。 例如: http://www.mysite.com/cms/?q=node/1 is redirected to… http://www.mysite.com/?q=node/1 我怎样才能做到这一点? 编辑:也在Drupal(cms)提供的.htaccess文件,这是写。 我试过启用它,但似乎没有任何效果。 # Modify the RewriteBase if you are using Drupal in a subdirectory or in a # VirtualDocumentRoot and the rewrite rules are not working properly. # For example if your site is at http://example.com/drupal […]
是否有可能重写图像? 图像存储在/very/big/path/1.jpg,我想/img/1.jpg如何做到这一点?
在我的新网站,我想有dynamic的子域名。 我正在努力使这个子域使用与主域相同的web根目录,所有这些都在一个CodeIgniter安装下。 例如,subdomain.example.com会导致example.com/subdomain,它实际上是example.com/index.php/subdomain。 我已经build立了虚拟主机的DNS,但是我却陷入了.htaccess 。 链接htaccess的效果是,当导航到任何子域时,它会陷入无限循环。 ( 一个请求后出现错误日志。 )这对www。应该是相同的效果,应该只是parsing到主域。
我们在一个networking解决schemeVPS上,四个域名都是一个IP。 在单个域的vhost.config文件中,以下内容将起作用: Redirect 301 /1234 http://example.com/ 但以下3个重写将不起作用: RewriteEngine On RewriteRule ^1234$ / [R=301,L] Options +FollowSymlinks RewriteEngine On RewriteRule ^1234$ / [R=301,L] Options +FollowSymlinks RewriteEngine On RewriteRule ^1234$ http://example.com [R=301,L] 这些只是testing,以获得一些更严重的事情与mod重写在vhost.config。 我觉得我必须错过简单的东西。 如果任何人都可以帮助我,这将不胜感激。
伙计们! 有一个Apache的mod_proxy问题,希望有人能帮助 前言:我们需要一个新的域( http://section1.info )来引导用户访问( http://domain.info/?q=section1 )并在URL中保留section1.info。 以下似乎不工作: ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://domain.info/?q=section1 ProxyPassReverse / http://domain.info/?q=section1 谢谢!
我有一个涉及PHP和mod_rewrite的问题。 我正在尝试加载页面example.com/1 。 的index.php <?php // get requested uri $uri = explode('/', strtolower(substr($_SERVER['REQUEST_URI'], 1))); var_dump($uri[0]); // route current page if ($uri[0] == '1'){ $page_id = '<br />1'; } else { header("HTTP/1.0 404 Not Found"); } echo $page_id; ?> var_dump给出string(1) "1"并且回显的page_id是1 。 问题是,我也收到以下警告。 PHP警告:无法修改标题信息 – 在第12行的/ PATH中已经由(path:6处开始的输出)发送的标题 第6行是var_dump。 第12行是标题行。 我不应该得到这个警告,因为代码不应该得到运行。 的.htaccess RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f […]
我非常,非常(非常!)使用国防部重写新…我有以下设置在我的htaccess,它的工作原理如预期删除.php扩展名。 我的问题是如何让url不扩展,如果有人把任何扩展到url的结尾? 现在http://www.example.com/share等工作,但也是http://www.example.com/share.php 。 我想删除这些页面上的任何扩展名! Options +FollowSymlinks RewriteEngine on # remove php extension from all matching files RewriteRule ^(share|invite|submission|thankyou|confirm|over|report)$ $1.php [NC] 我已经尝试了几件事情,总是最终破坏这两个function。 由于某些原因,这些东西是find快速的谷歌答案最不可能的事情。 提前致谢! 更新:以某种方式工作,但获得无限的redirect循环: Options +FollowSymlinks RewriteEngine on # reslove extensionless urls RewriteRule ^(share|invite|submission|thankyou|confirm|over|report|emailtest)$ $1.php [NC] # make .php redirect to extensionless urls RewriteRule ^(share|invite|submission|thankyou|confirm|over|report).php$ /$1 [R=301,L,QSA]
我有一个虚拟主机configuration文件,我不能直接编辑或修改,因为它是由我们的主机平台Aegir生成的。 但是,它具有Include pre.d和Include post.d语句,这些语句包含在vhostconfiguration之前和之后。 我想要做的是在独立文件中添加特定于虚拟主机的重写规则,以便在向群集添加新服务器时自动迁移。 所以在pre.d我创build了一个名为ServerName_redirects.conf的文件,其中我放置了以下内容: <VirtualHost *:80> RewriteEngine on RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^servername.com$ [NC] RewriteRule ^/*(.*)$ https://servername.com%{REQUEST_URI} [L,R=301] </VirtualHost> 这只是网站迁移到新平台期间将要使用的许多规则之一。 但它不起作用,直到我把它包装在一个<VirtualHost servername.com:80> – 块。 但是由于VirtualHost-blocks并没有从原始虚拟主机的configuration中inheritanceDocumentRoot和ServerName ,所有的URL最终都会以404结尾,除非它们将stream量redirect到外部站点。 我不能简单地将DocumentRoot或ServerName添加到ServerName_redirects.conf文件,因为这些文件是“dynamic的”,并且可以随时在Aegir中的服务器或平台之间移动站点时进行更改。 尽pipe每个DocumentRoot的.htaccess都能解决这个问题,但是我不能使用它,因为它是一个Drupal多站点设置,而且我将不得不将每个站点的重写规则放在与RequestCond %{HTTP_HOST} ^www.site-1.com$相同的.htaccess文件中。 RequestCond %{HTTP_HOST} ^www.site-1.com$为每个规则,这不是特别优雅,我担心如何影响性能。