Php-url空间由.htaccess文件替换为短划线(-)


Php url space replace with dash(-) by .htaccess file

我有类似的php链接

echo "<h4><a href='$bname_d'>$bname_d</a></h4>'

如果$bname_d=Creativeartbd主机公司,则url显示

http://mysite.com/Creativeartbd host company (2 space in this url)

那么,我该如何用php/.htaccess用破折号替换这个空格呢?

目前我使用以下.htaccess规则

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /businesspage.php?page=$1 [L]

谢谢你的帮助。

通过以下方式传递url<?php $bname_d = str_replace(' ','-',$bname_d); ?>将用"-"替换空格