我有專門的服務器運行CENTOS 6.9 x86_64 xen hvm,cPanel & WHM 64.0(build 15),Apache 2.4.25和PHP 5.6.30。Apache htaccess - 如何重寫URL以包含頁面的廣告名稱值?
我的網站的.htaccess文件目前包括以下內容並正在按預期:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
ErrorDocument 404 /404.php
由於我沒有經驗與mod_rewrite的和PHP,我需要用以下幫助:
我的網站包含的個人資料不同型號的頁面。 的電流模型輪廓URL的例子被寫成這樣:
http://www.mywebsite.com/profile.php?id=123
我想的URL來代替重新寫爲:
http://www.mywebsite.com/profile/123/model-ad-name-here
爲了顯示(在profile.php頁面中)模型的廣告名稱,我有以下代碼:
<?php require_once('cms/includes/init_files.php');?>
<?php
$id = getParam('id');
$query_string = "SELECT * from profiles where id='$id'";
$query = $db->query($query_string);
$data = $db->fetch_assoc($query);
?>
...並顯示profile.php頁面本身的廣告名稱值,我用的是代碼:
<?php echo ucfirst($data['ad_name']); ?>
1)我需要添加到.htaccess文件什麼來重新寫入網址以我上面提到的格式和...
2)是否有任何特殊的代碼,我需要編輯/添加到profile.php頁面,以幫助協助?
我很感謝您對此提供的任何專家協助。