[英]How to remove id and title from url and rewrite it with domain followed by title name only?
我想從URL中刪除id並用域重寫它,然后只為SEO-frendly URL重寫標題名稱。
http://www.eyecatchers.co/testblog1.php?id=110&title=6-Benefits-of-Hiring-a-Digital-Marketing-Agency.
這是我當前的URL,我想通過.htaccess
將其重寫為以下URL
http://www.eyecatchers.co/6-Benefits-of-Hiring-a-Digital-Marketing-Agency.
我試過了
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule id/(.*)/(.*)/ testblog1.php?id=$1&title=$2
RewriteRule id/(.*)/(.*) testblog1.php?id=$1&title=$2
但它給了我
http://www.eyecatchers.co//id/110/6-Benefits-of-Hiring-a-Digital-Marketing-Agency.
如何才能獲得域名和標題名稱?
這一個正則表達式可能有所幫助
preg_replace("/testblog1\\.php\\?id=\\d*&title=/", "$1", $input_lines);
所以
http://www.eyecatchers.co/testblog1.php?id=123&title=your-title
如此
http://www.eyecatchers.co/your-title
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.