我们有这样的链接,
turkish-property-world.com/turkey_villas.php?bid=4&page=1
想表明,
turkish-property-world.com/turkey_villas
在.htaccess中我们包含规则但没有任何变化。
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
任何帮助?
答案 0 :(得分:2)
有一个Javascript解决方案,它很简单,但不是很优雅。仍然:
//get the url
$old_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
//remove everything after '.php' in the url
$new_url = substr($old_url, 0, strpos($old_url, '.php'));
//then with javascript you replace the url with the new one
<script type="text/javascript">
if(new_url != '')
{
window.history.replaceState({"html":'Title',"pageTitle":'Page Title'}, '', new_url);
}
</script>
答案 1 :(得分:1)
您可以使用以下内容;
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ $1.php?bid=$2&page=$3 [L]
通过这样做,
turkish-property-world.com/turkey_villas.php?bid=4&page=1
将是
turkish-property-world.com/turkey_villas/4/1
您还需要关键其他参数
更新:上述规则不仅适用于turkey_villas
,还适用于其他* .php名称
答案 2 :(得分:1)
RewriteRule ^turkey_villas$ villas.php?bid=$1&page=$2 [NC,L]
在&#34; villas.php&#34;文件获得这样的出价$ _GET [&#39; bid&#39;];