Articles of mod rewrite

apache点通配符子域到目录?

随着Apache,我想要一个通配符,所以我的域可以去适当的文件夹。 www应该忽略/进入根目录。 我如何设置规则? 'domain.com' to go to '/var/www/prj/www/root' 'ANYTHING.domain.com' to go to '/var/www/prj/www/ANYTHING' 目前我的文件是 <VirtualHost *:80> ServerName domain.com ServerAlias *.domain.com DocumentRoot /var/www/domain/www </VirtualHost>

重写条件反向引用传递给所有规则?

有没有办法取回重写条件的引用传递给所有后续的重写规则? 这是一个例子: RewriteEngine On RewriteCond %{HTTP_HOST} (bob).localhost [NC] RewriteRule ^/where/? /index.php\?user_name=%1 RewriteRule ^/who/? /index.php\?user_name=%1 在这个例子中,我期望这个行为: http://bob.localhost/where => http://bob.localhost/where/index.php?user_name=bob http://bob.localhost/who => http://bob.localhost/who/index.php?usern_ame=bob 但是对于第二条规则,我接收http://bob.localhost/who/index.php?user_name = 。 我已经尝试了几个不同的发行版使用Apache 2.2.17

RewriteCond不能在Apache上工作(但启用)

我在我的apache错误日志文件中得到这些错误: [Fri May 20 16:17:06 2011] [notice] Apache/2.2.17 (Ubuntu) PHP/5.3.5-1ubuntu7.2 with Suhosin-Patch configured — resuming normal operations [Fri May 20 16:17:11 2011] [alert] [client 127.0.0.1] /home/zomerovic/vhosts/brillelook/public_html/.htaccess: Invalid command 'RewriteCond', perhaps misspelled or defined by a module not included in the server configuration [Fri May 20 16:17:12 2011] [alert] [client 127.0.0.1] /home/zomerovic/vhosts/brillelook/public_html/.htaccess: Invalid command 'RewriteCond', perhaps […]

redirect目录使用Apache mod重写

我有名为/template/css目录 完整的url是http://sitename.com/template/css 我需要这个文件夹被redirect使用Apache国防部重写 从 http://sitename.com/template/css 至: http://sitename.com/css 我怎样才能做到这一点?

Apache:mod-rewrite在另一个目录中查找丢失的图像

我是Apache mod重写的新手。 我想达到的是这个。 如果一个图片(gif,jpg,png)被请求从一个url,并没有在那里find,它应该会自动尝试从另一个目录提供这个图像。

使用mod_rewrite将单个IP地址发送到特定页面

我们的CentOS VDS上的Apache正受到托pipe公司的监控(由于之前在共享托pipe服务器上的问题)。 他们正在监控的网站是一个在线商店,而且这样做有一个相当不幸的副作用,就是在任何特定时刻,看起来好像有众多的访问者在线。 它也用不相关的条目填满商店的日志。 这些都不是关键,但我想消除这些问题。 我试图在.htaccess文件中使用mod_rewrite命令将一个IP地址redirect到一个虚拟页面,而不是让它进入商店。 谷歌search产生了很多例子,但他们都是为了一个特定的页面的请求,而在我的情况下,没有页面被要求。 这是我结束了(192.168.0.23是我的testing客户端),但它只是导致一个循环: RewriteCond %{REMOTE_HOST} 192\.168\.0\.23 RewriteRule .* /monitor.html [R=301,L] 此示例正在使用wget(使用IP地址或域名)在我的开发服务器上进行testing,结果如下: H:\>wget http://192.168.0.18 –2011-09-26 09:01:07– http://192.168.0.18/monitor.html Connecting to 192.168.0.18:80… connected. 反复重复,直到 –2011-09-26 09:01:07– http://192.168.0.18/monitor.html Connecting to 192.168.0.18:80… connected. HTTP request sent, awaiting response… 301 Moved Permanently Location: http://192.168.0.18/monitor.html [following] 20 redirections exceeded. 是我试图做的可能使用mod_rewrite或者我应该解决这个其他方式? TL;博士: 我需要将来自特定IP地址的任何请求redirect到虚拟页面 响应必须来自Web服务器,因为这是被监视的 编辑 这是执行另一个wget http://192.168.0.18后的rewrite_log的内容 192.168.0.23 […]

mod_proxy映射http:// myserver /游戏到http:// localhost:5732 /?

N00b的问题。 我有一个url http://myserver.com/game 并想调用内部资源 http://localhost:5732/ 我试过了: AllowCONNECT 5732 ProxyPass /game/ http://localhost:5732/ nocanon ProxyPassReverse /game/ http://localhost:5732/ 但回来的HTML包含的链接没有得到/游戏/ prepended和JS和CSS中断。 所以我试了一下: RewriteEngine On RewriteRule ^/game(.*) http://localhost:5732$1 但是发送redirect(当然不起作用)到浏览器。 我错了什么? 我的目标是: http://myserver/game –> http://localhost:5732/ 非常感谢帮助

如何根据用户区域设置redirect到给定页面?

有没有办法根据浏览器语言环境redirect用户? 例如,我想redirect到一个名为index.en.html的页面,所有没有设置为法语的浏览器语言环境的用户。 我可以用Apache和.htaccess来做这个吗?

Apacheredirect没有URL重写

有没有一种方法可以实现redirect到另一个网站,而不会丢失原始url? 所以,我们想要达到的是能够访问: somesite.com/some/url -> someothersite.com/some/url 但我们希望保留somesite.com/* 。 换句话说,我们希望通过somesite.com访问someothersite.com 每个url 。

Apache自动完成url

看到这NYTimesurl: 如果我们input opinionator.blogs.nytimes.com/2011/01/02/war-i 在浏览器中,它会自动将我们redirect到上述文章,该文件夹中以“war-i”开头的唯一文章。 如何在一个网站与Apache,只提供静态html文件? 也就是说,如果有一个Apache模块,而不添加脚本,那将是最好的。