简体   繁体   中英

Apache2: Rewrite url to different port on localhost

There is a service on my local computer available on 127.0.0.1:8080 , but I would prefer to use it rather like 127.0.0.1/qwerty/

I tried to add in /etc/apache2/sites-available/default :

RewriteEngine on
RewriteRule (qwerty/.*)$ http://127.0.0.1:8080/$1 

Before that I symlinked rewrite.load in mods-enabled and restarted apache2 server.

Unfortunately, it doesn't work.


Edit: To be more specific - This service is calibre-server and its output is on port 8080 , while on port 80 works apache2. Then I'd like to do the same with my flask (python micro framework) project (it works on port 5000 ).


Edit 2: I used reversed proxy trick from link , typing calibre-server --url-prefix /calibre in command line and it works ( without proxying anything i needed to set proxy in /etc/apache2/sites-available/default ).

What does not work is this flask thing.

I will write down everything I did, because I'm not sure I understood correctly. @Ωmega : I do start flask project by typing python demo.py in demo directory. I created .htaccess file in this directory and put there the line you've suggested and it didn't work, so I changed all file content to:

Options FollowSymLinks
RewriteEngine On
RewriteRule ^$ http://127.0.0.1/flask/ [R=301,L]

but it still doesn't work.

在提供http://127.0.0.1:8080 目录的设置中,执行以下重定向:

RewriteRule ^$ http://127.0.0.1/qwerty/ [R=301,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM