无法启用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 values include: debug, info, notice, warn, error, crit, # alert, emerg. # LogLevel debug rewrite:trace8 

…在这两种情况下,我都没有在error.log中提到[rewrite]

最后,这里是httpd.conf的一部分,其中有重写规则本身和反向代理的东西:

 <Directory /> Options All AllowOverride All LogLevel debug rewrite:trace8 RewriteEngine On # Turn on the rewriting engine RewriteRule ^Dashboard$ Dashboard?Category=Furniture [NC] </Directory> #####Proxy Rule ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://server8/ ProxyPassReverse / http://server8/ 

当我执行stringhttp://localhost:9089/views/JavaScriptTarget/Dashboard我被正确地redirect到http://server8/views/JavaScriptTarget/Dashboard …但是?Category=Furniture没有被追加。

任何线索我在这里做错了什么? 我机智的结局。 甚至不能达到我可以得到重写错误显示在日志中的地步!

我在Windows x64上的2.4.4(Win7),顺便说一句…

您的RewriteRule“^ Dashboard $”意味着URLstring在“Dashboard”之前没有任何内容,没有任何内容。 那是你要的吗? 看起来像你的url是“/ views / JavaScriptTarget /仪表板”。

也许这并不重要,但我不会把重写规则在configuration – “目录”指令我不是专家,因为我主要使用Apache的反向代理,我只是不会最终使用它。

所以,这一切都将最终代理到您的后端服务器“server8”。 再次确认您的服务器8上没有使用服务器的主机名进行redirect。 如果你明白我的意思,你可以使用“/”做redirect,但是不能使用“{servername} /”。

我会设置下面的configuration来实现你想要的。

 RewriteEngine On RewriteRule ^/views/JavaScriptTarget/Dashboard /views/JavaScriptTarget/Dashboard?Category=Furniture [PT] ProxyPass / http://server8/ ProxyPassReverse / http://server8/