我想启用重写日志logging,以便我可以debugging重写规则,但添加RewriteLog指令导致500错误。 版本信息: Ubuntu 14.04 Server version: Apache/2.4.12 (Ubuntu) Server built: Feb 4 2015 14:22:06 .htaccess内容 <IfModule mod_rewrite.c> RewriteEngine On RewriteLog /var/log/apache2/rewrite.log RewriteLogLevel 5 RewriteBase / RewriteRule ^/wordpress/wp-content/(.*)$ /wp-content/$1 [L] RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> 在错误日志中我看到: /var/www/path.to/wordpress/.htaccess: Invalid command 'RewriteLog', perhaps misspelled or defined by a […]
我有一个需要确保我的url,称为www.domain.com总是至less通过基本的HTTP身份validation保护。 此外,我想使用mod_rewrite将我的用户发送到我的服务器上运行的两个OC4j实例之一。 我也想用这个相同的authentication保护我的OC4jpipe理面板(和其他pipe理types的function)。 我将有2个用户,称他们pipe理员(pipe理员将有权访问OC4j实例和OC4jpipe理面板)和来宾(来宾将只能够到达OC4j实例)。 所以,假设我有两个OC4j实例 – instance_a和instance_b。 instance_a将在端口8888上运行,而instance_b将在端口8889上运行。当用户inputwww.domain.com/instance_a时,我想首先确认它们已经通过服务器authentication,然后我想使用mod_rewrite将请求代理到www .domain.com:8888 / instance_a。 这将遵循instance_b。 同样,任何用户,pipe理员或访客都可以访问这些实例。 如果用户试图直接访问OC4jpipe理面板,如果他们不是pipe理员用户,我想把它们踢出去。 我有一个像这样的VirtualHost条目: <VirtualHost *:80> ServerName www.domain.com CustomLog "/var/log/httpd/ic/access_log" "combined" ErrorLog "/var/log/httpd/ic/error_log" RewriteEngine on RewriteLogLevel 9 RewriteLog "/var/log/httpd/rewrite_log" RewriteCond %{REMOTE_USER} !^guest$ [OR] RewriteCond %{REMOTE_USER} !^admin$ RewriteCond %{REQUEST_URI} ^/instance_a.*$ RewriteRule ^.*$ – [F,L] <LocationMatch "^/.*$"> AuthType Basic AuthName "Please Login" AuthBasicProvider file AuthUserFile /usr/local/apache/passwd/passwords […]
如何在这些forms的url的MVC系统强制通过一个单一的index.php文件的所有请求? http://www.example.com/foo/bar/baz http://www.example.com/goo/car/caz/SEO-friendly-name-of-the-object http://www.example.com/hey/you 编辑:当我尝试下面的重写规则,我得到这个错误: [error] [client 127.0.0.1] Invalid URI in request GET / HTTP/1.1 [error] [client 127.0.0.1] Invalid URI in request GET /abc HTTP/1.1 编辑:哦,这是/index.php的完整内容。 当我删除重写规则时,它输出“/”或“/index.php”,或者我得到一个404其他任何东西。 <?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?> 求解:我在重写规则中的index.php前面添加了一个/然后它工作: 重新求解:结果只是因为我正在运行2.2.4。 当我升级到2.2.11时,/不再需要。
对于切诺基来说,我相当陌生,除了URL Rewrites之外,它是非常棒的。 有一个简单的向导吗? 让我知道。 另外我将如何移植这个: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 谢谢
我正在使用以下代码将所有www请求指向非wwwurl: RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.org$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] 这在我的网站根目录下的.htaccess文件里面工作的很好。 例如, www.example.com – > example.com/ www.example.com/ – > example.com/ www.example.com/other_page – > example.com/other_page 但是,如果将相同的代码移到我的VirtualHostconfiguration中,则重写的URL将包含一个双尾斜杠。 www.example.com – > example.com// www.example.com/ – > example.com// www.example.com/other_page – > example.com//other_page 我通过从重写规则中删除斜线来修复它: RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.org$ [NC] RewriteRule ^(.*)$ http://example.com$1 [R=301,L] 但是我不明白这个原因。 任何人知道为什么
我想301将所有example.orgredirect到www.example.org。 下面的例子就是这样做的,但是它有很多的噪音,因此很难维护和容易出错: <VirtualHost 192.0.2.123:80> ServerName example.org RedirectPermanent / http://www.example.org </VirtualHost> <VirtualHost 192.0.2.123:80> ServerName www.example.org DocumentRoot /usr/local/www/example </VirtualHost> 你碰巧知道上面的整个事情是否有一些较短的版本? 像这样的伪configuration : <VirtualHost 192.0.2.123:80> ServerName www.example.org ServerAlias example.org # Redirect-Every-ServerAlias-To-ServerName DocumentRoot /usr/local/www/example </VirtualHost> 那么这样我只需要提供每个应该在ServerAlias下redirect的子域呢?
我们最近把我们的Web服务器之一切换到apache 2.4,并通过php-fpm和mod_proxy_fcgi运行PHP。 大多数一切运作良好,但有一个问题我还不明白。 我们的一个网站正在运行WordPress,它在.htaccess文件中带来了一个很好的重写规则列表。 而且似乎这些在vhost安装中的ProxyPass指令不能很好地工作。 我们的虚拟主机包含以下configuration: ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.2:9126/<path>/$1 这在大多数情况下工作。 现在,htaccess文件除其他外,还包括: RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ – [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteRule . index.php [L] 由于该站点是子目录中的多路博客,我读了URL /blogname/wp-admin/load-styles.php?xxxx应该被重写为wp-admin / load-styles.php?xxx(第二个重写规则)。 但是看看mod_proxy日志,实际传递的请求是/blogname/wp-admin/load-styles.php。 我认为这是因为存在一个优先问题 – ProxyPass规则在所有的RewriteRules都被解决之前触发。 我受阻 – 可能是什么原因?
这个重写规则有一个奇怪的场景: RewriteCond img/$2/$3/$4/$1 -f RewriteRule ^img/(([a-z0-9]{4})([a-z0-9]{4})([a-z0-9]{4})[a-z0-9]{28}\.\w+)$ img/$2/$3/$4/$1 [L] 这个目录结构是(简化): var/ images/ .. www/ .htaccess img -> /var/images 换句话说,图像存储在通用数据存储区域的webroot之外,并通过符号链接链接到webroot的img目录中。 图像名称是散列。 为了提高效率,它们被存储在三层深的目录层次结构中。 例如: 0a808e34edaaeeffd973e4138789a4957d6b6a26.jpg 存储在 images/0a80/8e34/edaa/0a808e34edaaeeffd973e4138789a4957d6b6a26.jpg 重写规则只是将文件名重写为嵌套的目录结构。 现在,奇怪的是, RewriteCond在我的本地系统上正常工作,但在testing服务器上失败。 Apachedebugging日志明确指出,“- -f模式不匹配”这种情况。 如果我只是删除这个条件重写规则工作正常,图像被送达。 什么可能导致-f文件显然存在失败? FollowSymLinks是允许的。 Apache版本2.2.22-6ubuntu2通过apt安装,几乎没有修改。 在Apache 2.2.23的本地安装上工作(通过自制软件)。 在这两个版本之间看不到任何重大的变化 。 关于实际目录结构的一些更可能的重要细节: $ ls -l /var/www/myapp/current [snip] /var/www/myapp/current -> /var/www/myapp/releases/20130418090750 $ ls -la /var/www/myapp/current/webroot [snip] [snip] .htaccess [snip] img […]
我有一个(简单的亚马逊)负载平衡器后面的apache服务器。 我想redirect到443不是443的任何传入stream量。我宁愿它只使用一个apache虚拟主机。 所以我试图检测,如果HTTP_X_FORWARDED_PORT标头不是443。 我已经检查了RewriteCond文档 ,它只适用于一套有限的HTTP头文件。 基本上我正在做的是这样的: <VirtualHost *:80> ServerName www.example.com RewriteEngine On RewriteCond %{HTTP_X_FORWARDED_PORT} !=443 RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] …. </VirtualHost> 但RewriteCond不识别HTTP_X_FORWARDED_PORT。 有没有其他的方法来完成这个(只有一个VirtualHost)? (一些types的传入头检查?) 谢谢,兰斯
即时通讯设法设置Apache与SSl和代理SSL请求到我的Tomcat实例。 我想我做了SSL的工作,但仍然是一个错误,显示: Bad Gateway The proxy server received an invalid response from an upstream server. * SSL虚拟主机* LoadModule ssl_module modules/mod_ssl.so Listen 443 <VirtualHost _default_:443> SSLEngine On SSLProxyEngine On DocumentRoot "/var/apache-tomcat-7.0.34/webapps/Learn2Gether/" SSLCertificateFile /etc/pki/tls/learn2gether/cert-6090205098829887.pem SSLCertificateKeyFile /etc/pki/tls/learn2gether/private_key_unlocked.pem SSLCertificateChainFile /etc/pki/tls/learn2gether/rubca-chain.pem BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0 SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL ServerName www.learn2gether.rubel.rub.de ServerAlias learn2gether.rubel.rub.de #RewriteRule ^\/$ /Learn2Gether/index.html [PT] ##RewriteRule ^/(.*)$ /$1 […]