URL은 http://www.test.co.uk/?set_cp_city=thecity
입니다. 일반적으로 $_GET['set_cp_city']
을 사용할 수는 있지만 작동하지 않습니다. 아마도 워드 프레스와 관련이 있습니다. 그래서 내가 매개 변수 set_cp_city
URL의 특정 매개 변수 가져 오기
Here'ss 내 코드
<select onChange="window.location.href=this.value">
<?php
$locations = array("London","Bristol","Manchester","Kent","Essex","Lancashire","Bedfordshire","Berkshire","Buckinghamshire","Cambridgeshire","Cheshire","Cornwall","County Durham","Cumbria","Derbyshire","Devon","Dorset","East Yorkshire","East Sussex","Gloucestershire","Hampshire","Herefordshire","Hertfordshire","Isle of Wight","Leicestershire","Lincolnshire","Merseyside","Norfolk","North Yorkshire","Northamptonshire","Northumberland","Nottinghamshire","Oxfordshire","Rutland","Shropshire","Somerset","South Yorkshire","Staffordshire","Suffolk","Surrey","Tyne and Wear","Warwickshire","West Midlands","West Sussex","West Yorkshire","Wiltshire","Worcestershire");
$current_city = $_GET['set_cp_city'];
echo "<option>$current_city</option>";
foreach($locations as $value) {
?>
<option value="http://www.test.co.uk/?set_cp_city=<?php echo $value ?>"><?php echo $value ?></option>
<?php
}
?>
</select>
'.htaccess'를 확인하고 if '[QSA]'가 그 안에 있습니다. 그렇지 않으면'ReWrite *'줄 중 하나 뒤에 추가해야 할 수도 있습니다. – Gary