我想从网址中删除id并使用域名重写,然后仅为SEO-frendly URL重写标题名称。
http://www.eyecatchers.co/testblog1.php?id=110&title=6-Benefits-of-Hiring-a-Digital-Marketing-Agency.
这是我当前的网址,我想通过.htaccess
将其重写为以下网址
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.
我如何才能获得域名和标题名称?
答案 0 :(得分:0)
这一个正则表达式可能会有所帮助
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