简体   繁体   English

用htaccess中的端口重写URL

[英]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 我需要帮助将以下URL重写为: http://example.com:7071/hotels_index/1 : http://example.com/hotels_index_1.json : http://example.com:7071/hotels_index/1 / http://example.com/hotels_index_1.jsonhttp://example.com:7071/hotels_index/1 : 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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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