开发者

Apache rewrite rule with proxy flag fail to work for mediawiki service

开发者 https://www.devze.com 2023-03-09 13:13 出处:网络
I have a local apache httpd hosting a mediawiki service that listen to port 3300.The service may access in my LAN via

I have a local apache httpd hosting a mediawiki service that listen to port 3300. The service may access in my LAN via

http://mylan:3300/wiki/

开发者_运维问答I configure my internet router to add a port forwarding entry to the mylan:3300. I may then access to the wiki via something like:

http://<dynamic domain>:3300/wiki/

Next, I have a web site that serve globally. The web server is apache httpd too. I add a rewrite rule in .htaccess:

RewriteEngine On
RewriteRule ^/?wiki/?$ http://<dynamic domain>:3300/wiki/ [P]

I wish to access the wiki that host on my local LAN via the proxy method but using the global internet domain namespace:

http://<internet domain>/wiki/

After execute the above URL from internet browser, I can see the wiki contents. However, the URL shown in address bar change to

http://<dynamic domain>:3300/wiki/index.php/Main_Page

In order to test the proxy rewrite rule work, I try to change the rewrite rule to:

RewriteRule ^/?wiki/?$ http://www.google.com/search?q=test [P]

Open the URL:

http:///wiki/

lead me to google search page but the URL remain as http:///wiki/.

Any ideas why the rewrite rule

RewriteRule ^/?wiki/?$ http://<dynamic domain>:3300/wiki/ [P]

make the browser show the new URL address instead of internet domain name space:

http://<internet domain>/wiki/

A good example is:

RewriteRule ^/?wiki/(.*)$ http://en.wikipedia.org/wiki/$1 [P]

If we access the url:

http://<domain>/wiki/Country

The URL will always rewrite and shown as

http://en.wikipedia.org/wiki/Country

Instead, I expect it to show as

http://<domain>/wiki/Country

but the content is from http://en.wikipedia.org/wiki/Country


Probably a redirect that includes the full link. To rewrite them add something like:

ProxyPassReverse /wiki/ http://<dynamic domain>:3300/wiki/

I also notice in the Apache online documentation for URL Rewriting Guide - Advanced topics in the section on Content Handling, sub section Dynamic Mirror has this example:

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^hotsheet/(.*)$  http://www.tstimpreso.com/hotsheet/$1  [P]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号