简体   繁体   中英

Rewrite URL with port in htaccess

I need help rewriting the following URL: http://example.com:7071/hotels_index/1 to this: http://example.com/hotels_index_1.json

So far I've got:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/?([^/]+)_([^/]+)_([0-9]+)\.json$ http://example.com:7071/$1_$2/$3 [L]

You can use this code:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^(.+?)_([0-9]+)\.json$ http://%{HTTP_HOST}:7071/$1/$2 [L,R]

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