2017-04-03 85 views
-2

如何更改核心PHP中的URL?請讓我知道如何做到這一點如何更改核心PHP中的URL

http://localhost/files/rajfireworks/product_details?pro_id=2 

http://localhost/files/rajfireworks/product_details/productname 
+1

嘗試的.htaccess http://stackoverflow.com/questions/11899769/sef-url-without-name-with-core-php-and-htaccess –

+1

可能重複的[Apache重寫 - 乾淨的URL在本地主機](http://stackoverflow.com/questions/19211824/apache-rewrite-clean-urls-in-localhost) – Dez

回答

0

這可以幫助:

<?php 
if(!empty($_GET['pro_id'])) { 
    header("Location: /files/rajfireworks/product_details/productname"); 
}  
?> 

取決於product_id號 - 你可以擴展你的條件。

+0

感謝您的回覆,pro_id正在動態獲取。 MORE DETAILS

0

這可以幫助你:

在你的.htaccess文件中寫下面的代碼。

對於內頁寫: 重寫規則^產品/([^ /] +)product_details.php名= $ 1 [NC]

對於所有產品頁面: 重寫規則^產品產品。 php [NC]

0

您可以在htaccess文件中使用URL重寫。在主文件夾

把.htaccess文件,並使用下面code.It會念想,如果你的URL http://example.com/index.php?page=search它會顯示這樣的http://example.com/search

代碼:

RewriteEngine on 
RewriteCond %{THE_REQUEST} /product\.php\?cat=(search) 
RewriteRule^/%1? [R=302,L] 
RewriteRule ^(search)$ /product.php?page=$1 [L,QSA]