【问题标题】:Rewrite URL with port in htaccess在 htaccess 中使用端口重写 URL
【发布时间】:2013-10-08 14:35:25
【问题描述】:

我需要帮助重写以下 URL: http://example.com:7071/hotels_index/1 对此: http://example.com/hotels_index_1.json

到目前为止,我得到了:

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

【问题讨论】:

    标签: regex apache .htaccess mod-rewrite url-rewriting


    【解决方案1】:

    您可以使用此代码:

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

    【讨论】:

      猜你喜欢
      • 2012-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-03
      相关资源
      最近更新 更多