Articles of mod rewrite

mod_rewrite规则删除.php扩展名现在显示完整的文件系统path

我正在将一个站点从Wordpress迁移到Octopress – 但是已经设法完成了mod_rewrite设置的过程。 目前,所有的url都是格式 http://site.com/archives/yyyy/mmm/posttitle.php 一旦移植到Octopress,他们现在的格式是: http://site.com/archives/yyyy/mmm/posttitle 也有一些顶级的网页是所有的变化 http://site.com/pagename.php 现在 http://site.com/pagename 我还有 RewriteRule ^(.+)\.php $1 这似乎很好地工作 – 但只要我包括301redirect: RewriteRule ^(.+)\.php $1 [R=301] 重写规则现在包括完整的文件系统path – 所以: http://site.com/var/www/octopress/archives/yyyy/mmm/posttitle.php 任何人都可以指出我哪里错了? ETA RewriteRule在<Directory>块中: <Directory /> ReWriteEngine On RewriteRule ^(.+)\.php $1 Options FollowSymLinks AllowOverride All </Directory>

无法启用Apache重写

Apache newb在这里。 最终目标是使用Apache作为反向代理(得到这个工作),并通过mod-rewrite将特定的值附加到查询string(无法得到它的工作)。 有问题的string是: http://localhost:9089/views/JavaScriptTarget/Dashboard …我想追加?类别=家具: http://localhost:9089/views/JavaScriptTarget/Dashboard?Category=Furniture 我已经启用了该模块: #LoadModule reqtimeout_module modules/mod_reqtimeout.so LoadModule rewrite_module modules/mod_rewrite.so #LoadModule sed_module modules/mod_sed.so 我曾尝试在许多地方启用重写日志logging: <Directory /> Options All AllowOverride All LogLevel debug rewrite:trace8 RewriteEngine On # Turn on the rewriting engine RewriteRule ^Dashboard$ Dashboard?Category=Furniture [NC] </Directory> …和: # # LogLevel: Control the number of messages logged to the error_log. # Possible […]

htaccess的问题 – 500内部错误

我已经安装了具有以下重写规则的应用程序。 它运行良好的VPS设置 – 但在每个共享主机显示500错误。 日志显示“bad delimiter” – 尝试一段时间后,我完全无能为力。 请帮忙 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteRule ^assets/css/(.*) /wp-content/themes/liinks theme/assets/css/$1 [QSA,L] RewriteRule ^assets/js/(.*) /wp-content/themes/liinks theme/assets/js/$1 [QSA,L] RewriteRule ^assets/img/(.*) /wp-content/themes/liinks theme/assets/img/$1 [QSA,L] RewriteRule ^plugins/(.*) /wp-content/plugins/$1 [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> 谢谢

mod_negotiation和mod_rewrite

我试图configuration一个URLscheme,a)允许“.html”扩展名被省略,b)在某些条件下发送403(禁止)错误。 但是,通过以下设置: Options +MultiViews RewriteRule ^foo/bar$ – [F] 如果我请求/foo/bar我得到一个404(未发现)错误与错误日志中的“无法协商”行。 请求/foo/bar.html 确实起作用,所以我猜测内容协商正在对RewriteRule进行“优先处理”,并且一直在寻找其他的URL,直到find200.事实上,我已经证实通过bar.txt文件和只针对.html文件的RewriteRule进行testing。 那么,有没有办法修改mod_negotiation的行为,只要遇到Forbidden错误就“放弃”? UPDATE 注:看起来好像我可以解决这个问题,通过禁用MultiViews和使用mod_rewrite,而不是例如 RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L] 但我猜测效率不高,而且configuration要多得多

mod_rewrite捕获域和tld

我正在使用mod_write来重写这个 www.variabledomain.variableext 至 http://my.com/variabledomain.variableext 请注意, variabledomain和variableext是真正的variables,所以我不能硬编码它们。 我不是mod_rewrite的专家,但我认为像这样的工作,但事实并非如此。 任何想法,而不是我应该做的。 RewriteRule ^(.*)\.(.*)\.(.*)$ http://my.com/$2\.$3 [R=301,L]

检查Apache的mod_rewrite

我想用Apache mod_rewrite做一些简单的事情。 猜猜看,这是行不通的。 如果我在“理智”的环境中,也许我会得到一个错误和堆栈跟踪。 或者也许我可以使用debugging器。 或者,也许%{REQUEST_URI}应该是一个variables,我可以在控制台中打印出来,而不是使用演绎推理来弄清楚它可能包含什么,也可能不包含。 当我在浏览器中input的url通过.htaccess时,怎么可能find什么步骤?

基于任意头的Apache反向代理逻辑

我有一个natting fw上运行的apache,validation,反向代理,并提供一个ssl封装2个webapps在后端。 这可以根据请求的顶级目录(例如https://example.com/app1/ <-> http://app1/app1/使用虚拟主机和代理。 (见图1) 我想find一种方法来代理请求到一个web服务基于请求中设置的任意头,例如,如果头web_service:coolwebservice设置,它代理回到webservice:8000。 这甚至有可能吗? fig1 [Apache:example.com:443 / FW / NAT] | ┌——————┬——————┐ | | | VVV [app1:80 / app1 /] [app2:8080 / app2 /] [web_service:8000]

如何configuration我的httpd重写/代理,以指导app1.example.com:443到本地主机:8080和app2.example.com:443到本地主机:8081?

我有两个Tomcat实例,一个在端口8080上运行,另一个在8081上运行。两者都部署了一个名为app.war的web应用程序,但它们不仅被不同的端口分开,而且被不同的数据存储区分开。 然而,每个运行在同一个物理盒子上。 我们组织中的防火墙规则指定我只能通过端口443提供HTTPS服务。不支持HTTP,也不支持80,8080或8081的HTTPS。 物理盒运行RHEL5,在eth0上运行一个IP。 DNS设置为映射到app1.example.com和app2.example.com的框。 如何configuration我的httpd重写/代理,以指导app1.example.com:443到本地主机:8080和app2.example.com:443到本地主机:8081? 编辑 : 这是我试过的… LoadModule ssl_module modules/mod_ssl.so Listen 443 NameVirtualHost *:443 ProxyRequests Off <VirtualHost *:443> ServerName app1.example.com SSLProxyEngine On SSlProxyMachineCertificateFile /etc/httpd/cert/10year.pem SSLVerifyClient Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / https://app.example.com: / ProxyPassReverse / https://app.example.com:8080/ ProxyPassReverseCookieDomain app.example.com app1.example.com <Location /> Order allow,deny Allow from all </Location> </VirtualHost> […]

redirect到新的域名并保留用户名

我最近切换到我运行版本控制服务器的新域。 服务器通常使用包含在URL中的用户名来访问,如https://[email protected]/some/stuff 。 我想redirect到旧域的请求到新的域,并保留在url(包括用户名)的一切。 所以前面的url会被redirect到https://[email protected]/some/stuff 。 目前我有以下重写条件和规则: RewriteCond %{HTTP_HOST} sub\.olddomain\.com RewriteRule (.*) https://sub.newdomain.net$1 [R=301,L] 这个工作除了丢弃URL的userinfo部分。 有没有一种方法可以保存用户信息?

apache mod_proxy或mod_rewrite用于隐藏path后面的web服务器的根目录

我有2个apache 2.2.21一个外部和一个内部,我需要映射内部apache在外部apache后面的path,但我有一些绝对url的问题。 我试过这些configuration: RewriteEngine on RewriteRule ^/externalpath/(.*)$ http://internal-apache.test.com/$1 [L,P,QSA] ProxyPassReverse /externalpath/ http://internal-apache.test.com/ 要么 <Location /externalpath/> ProxyPass http://internal-apache.test.com/ ProxyPassReverse http://internal-apache.test.com/ </Location> 我的内部apache使用search资源的绝对path作为图像,CSS和HTML,我现在不能改变它。 有些build议? 谢谢