我正在重写查询string到美丽的URI,例如: index.php?q=/en/contact成为/en/contact ,所有的作品很好.. # httpd.conf # HANDLE THE QUERY RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 甚至有可能重写单个查询来强制https和强制一切到http ? 我已经尝试了许多不同的方法,通常以无穷循环结束。 我可以写一个插件来做到这一点在PHP中,但认为这将是更有效的处理这在服务器conf。 我会很乐意提供任何build议。 编辑:为了澄清,我想能够重写非SSL http://example.com/index.php?q=/en/contact启用SSL https://example.com/en/contact并且每个不是/en/contact查询都被写入http://example.com/…
给定一个URL: http://example.com/some-file.zip example.com的文档根目录是/var/www/example.com/ 我想要apache: 1) If /var/www/example.com/some-file.zip exists, serve it. 2) If /var/www/example.com/some-file.zip doesn't exist, check /var/www/shared/some-file.zip 3) If /var/www/shared/some-file.zip doesn't exist, send a 404 这可能吗? 我查看了Alias指令,但是我认为这将需要我在URI中指定资源的位置。
哦,.htaccess伤了我的头。 所以,我有一个网页有一个漂亮的urlfoo.com/radio/jobs,虽然实际上住在foo.com/content/directory_jobs.php/?section=radio 我用一个.htaccess行来实现这个… RewriteRule ^(radio|tv|magazines|newspapers)/jobs$ /content/directory_jobs.php?section=$1 这个页面有一个可选的页面=查询string – 所以你可以去foo.com/radio/jobs?page=2看到第二页。 但是,上面的.htaccess行不会添加这个页面variables:其结果是底层PHP脚本没有看到“页面”variables。 我可以调整上面的.htaccess行以确保我传递一个“页”variables,如果它存在? 还是我必须有这样的每个页面两个.htaccess行?
我有一个网站,托pipe在一个Linux el cheapo托pipe服务,我正在迁移到我的Mac OS X 10.5豹服务器运行Apache 2.2.8和PHP 5.2.5瓦特/ rewrite_module启用和AllowOverride All ,但我在.htaccess文件中遇到以下问题: RewriteEngine On #RewriteRule ^view/([^/\.]+)/?$ /view.php?item=$1 [L] #RewriteRule ^order/([^/\.]+)/?$ /order.php?item=$1 [L] RewriteRule ^category/([^/\.]+)/?$ /category.php?category=$1 [L] 正如你所看到的,我已经注释到了/view/和/order/的RewriteRule指令,所以我只处理/category/ 。 当我尝试加载http://domain.tld/category/2/它运行category.php (我添加了debugging代码来确认),但$_SERVER['REQUEST_URI']通过/category/2/和$_GET['category']通过为空。 我通常罚款解决.htaccess文件和mod_rewrite指令,但这一个让我难住的原因。 更新 :我遵循乔希的build议 ,这里是什么被转储到mod_rewrite.log当我尝试访问http://domain.tld/category/2/ : 65.19.81.253 – – [22/Oct/2009:17:31:53 –0400] [domain.tld/sid#100aae0b0][rid#100b5ea98/initial] (2) init rewrite engine with requested uri /category/13 65.19.81.253 – – [22/Oct/2009:17:31:53 –0400] [domain.tld/sid#100aae0b0][rid#100b5ea98/initial] (3) […]
我正在运行CentOS 6.0,并试图使mod_rewrite从任何URL前缀删除www。 以下是我在httpd.conf中的代码: 注意:我正在使用具有完全根访问权限的VPS,所以我没有使用.htaccess文件或任何“每个目录”设置。 RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.aaronjwood\.com$ RewriteRule ^(.*)$ http://aaronjwood.com/$1 [R=301,L] 这对所有页面都是正常工作的,只不过url会写入http://aaronjwood.com// (注意两个斜线)或http://aaronjwood.com//contact.php 。 任何人都可以帮我找出为什么发生这种情况?
我的一个虚拟主机上有以下设置: …<VirtualHost *:80> ServerName cloud.domain.de ServerAdmin [email protected] ServerSignature Off Alias "/.well-known/acme-challenge" "/var/www/domain.de/vh-www/htdocs/public/.well-known/acme-challenge" <Directory "/var/www/domain.de/vh-www/htdocs/public/.well-known/acme-challenge"> Require all granted ForceType 'text/plain' </Directory> <ifmodule mod_rewrite.c> RewriteEngine On RewriteCond %(REQUEST_URI) !/\.well\-known/acme\-challenge/?.* RewriteCond %{HTTPS} off # RewriteRule ^\.well-known/acme-challenge/([A-Za-z0-9-]+)/?$ – [L] RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </ifmodule>… 我想要实现的是,当url http://cloud.domain.de/.well-known/acme-challenge/被访问时,mod_rewrite不会重写URL。 我已经尝试了不同的方法,其中之一是上面提到的RewriteRule,但似乎没有任何工作:服务器每次都将其重写为https。 当我禁用重写testing的目的,我可以访问别名的URL就好了… 如何实现特定的URL不被重写?
我知道像Cloudflare这样的CDN通过将静态文件caching为图像,JS和CSS文件来节省带宽。 我有一个脚本,dynamic生成图像,其位置如下所示: http://domain.com/image.php?id=1 用id是图像ID。 由于dynamicURL,Cloudflare不会caching这些图片。 如果我添加一个mod重写规则来重写URL成为类似于: http://domain.com/images/1 要么 http://domain.com/images/1.jpg 在这种情况下,CloudFlare会caching图像,还是图像实际上是驻留在目录中的真实文件?
我使用mod_rewrite运行一个CMS来pipe理漂亮的URL,但是我有另一个站点在CMS下面的一个子目录下运行,需要禁用URL重写,所以我在.htaccess文件中添加了几行代码: Options -MultiViews Options +ExecCGI AddHandler php5-cgi .php Action php-cgi /cgi-bin/php-wrapper.cgi Action php5-cgi /cgi-bin/php-wrapper.cgi <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Added following two lines RewriteCond %{REQUEST_URI} ^/dir/ RewriteRule ^(.+) – [PT,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> 这是有效的,但是/dir/下的其中一个目录是使用mod_auth保护的,并且仍然在被重写。 如果我在这个目录的.htaccess文件中取出Require valid-user指令,一切都很好。 这是受保护的目录中的.htaccess文件: RewriteEngine off AuthType Basic AuthName "Administration" AuthUserFile "/home/user/admin/.htpasswd" […]
基本上我想redirect到我的域的所有请求到一个特定的页面。 例如,将所有请求redirect到页面X,除非您已经在页面X上,在这种情况下,您应该只加载它。 但我的解决scheme只是创build一个无限循环:/ 我试过了… RewriteCond %{REQUEST_URI} !=/underconstruction.html RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !^/underconstruction.html RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
我正在尝试将我的网站的根目录redirect到https。 虽然重写发生,但https不会产生任何结果。 浏览器说。 connecting to thinkingmonkey.me…并停滞不前。 Listen 80 & Listen 443出现在conf文件中。 我重新启动了httpd。 我正在使用正确的证书文件和私钥文件。 httpd日志中没有错误, SSL日志 (我有一个单独的日志SS1)。 从字面上看,即使我尝试直接访问https://thinkingmonkey.me,也没有logging到SSL访问日志中。 一个netstat -pant | grep httpd netstat -pant | grep httpd有这样的: Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 :::443 :::* LISTEN 1334/httpd tcp 0 0 :::80 :::* LISTEN 1334/httpd 的.htaccess: RewriteEngine on RewriteBase […]