[英]Modify .htaccess for query strings
這是我的工作目錄
das
|__views
|__admin
|__doctor
|__user
|__find-doctor.php
|__process.php
|__show-result.php
|__index.php(landing page)
|__index.php(routing)
|__.htaccess
我現在擁有的 .htaccess 是
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /das/index.php [L]
我需要修改 htaccess 文件以發送查詢字符串,例如
localhost/user?doctor-id=2
這樣我就可以使用 URL 中的 id 來查詢數據庫
在.htaccess中
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index/([0-9a-zA-Z]+)-([0-9]+) .php?user=$1&id=$2 [NC,L]
PHP
<?php
$get_param_one = $_GET['user'];
$get_param_two = $_GET['id'];
echo $get_param_one;
echo $get_param_two;
?>
示例網址: https : //example.com?user=doctor&id=who
get_param_one = 醫生
get_param_two = 誰
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.