Htaccess规则用于重写参数

时间:2017-01-16 19:21:47

标签: php .htaccess parameters url-rewriting

所以我当前的网址是:https://example.com/uDoc?id=xx

使用重写,我希望它是https://example.com/display?id=xx&type=doc

真正的问题是,因为我还有一条规则(JS: function initMap() { var pointA = new google.maps.LatLng(51.7519, -1.2578), pointB = new google.maps.LatLng(50.8429, -0.1313), pointC = new google.maps.LatLng(51.2029, -0.1403), myOptions = { zoom: 7, center: pointA }, map = new google.maps.Map(document.getElementById('map-canvas'), myOptions), // Instantiate a directions service. directionsService = new google.maps.DirectionsService, directionsDisplay = new google.maps.DirectionsRenderer({ map: map }), markerA = new google.maps.Marker({ position: pointA, title: "point A", label: "A", map: map }), markerB = new google.maps.Marker({ position: pointB, title: "point B", label: "B", map: map }), markerC = new google.maps.Marker({ position: pointC, title: "point C", label: "C", map: map }); var circle = new google.maps.Circle({ map: map, radius: 1000, // 10 miles in metres fillColor: '#AA0000' }); circle.bindTo('center', markerC, 'position'); // get route from A to B calculateAndDisplayRoute(directionsService, directionsDisplay, pointA, pointB); } function calculateAndDisplayRoute(directionsService, directionsDisplay, pointA, pointB) { directionsService.route({ origin: pointA, destination: pointB, avoidTolls: true, avoidHighways: false, travelMode: google.maps.TravelMode.DRIVING }, function (response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } else { window.alert('Directions request failed due to ' + status); } }); } initMap(); )用于静默添加.php(uDoc?id = xx - > uDoc.php?id = xx,没有它,它会导致404错误)。 这有点干扰了目前给出的答案。

我已经摆弄了各种htaccess规则,但我没有取得好成绩:(

如果有人可以帮助我,我真的很感激,当涉及到htaccess规则时,我完全放弃......

1 个答案:

答案 0 :(得分:2)

您可以在根目录中使用此规则.htaccess:

QSA

id=xx标记可确保您现有的查询字符串,即{{1}}转移到新URI。