2013-03-10 31 views
0

我m是一新的SEO,做第一次提前完全糊塗瞭如何將這種,創建自定義重寫規則PHP文件

http://www.XXXXXXXX.com/demo/konkanconnect/realestate/index.php?pages=propertyforsell 
to 
http://www.XXXXXXXX.com/demo/konkanconnect/realestate/property/sell 

and 

http://www.XXXXXXXX.com/demo/konkanconnect/realestate/index.php?pages=details&property_id=68 
to 
http://www.XXXXXXXX.com/demo/konkanconnect/realestate/property/property-name 

如何做到這一點,給我一個線索,謝謝。

+0

Google「mod_rewrite」。 – str 2013-03-10 14:26:04

回答

1

建立一個.htaccess文件,並使用mod_rewrite:第二個規則

RewriteEngine On 
RewriteRule property/sell index.php?pages=propertyforsell [L] 
RewriteRule property/(.*) index.php?pages=details&property_name=$1 

注意,你不能在URL中property-name值轉換爲一個property_id直接。您必須將其作爲另一個參數傳入,或者從服務器上的名稱查找它。下面將實現你想要的:

RewriteRule property/([0-9]+)/(.*) index.php?pages=details&property_id=$1 

的文件應該放在你的demo/konkanconnect/realestate/目錄中。

+0

不工作的人,我的服務器有什麼問題? – Shyantanu 2013-03-10 15:06:33

+0

定義「不工作」。你究竟試圖訪問什麼? – BenM 2013-03-10 15:11:25

+0

我已經使用你的代碼像RewriteEngine RewriteRule ^([^ /] *).HTML $ /demo/konkanconnect/realestate/index.php?pages=$1 [L] 在我的htaccess文件中,仍然沒有給期望的結果 – Shyantanu 2013-03-10 15:18:24