php - .Htaccess Url 重写将 %20(空格)替换为 "-"

标签 php mysql .htaccess url-rewriting

我正在尝试编辑 mt .htaccess 重写 url。

这是我的网址: http://www.indojamtangan.com/jamtanganoriginal/Alexandre%20Christie

Alexandre Christie 是我的品牌参数。我想将我的 .htaccess 网址设置为 http://www.indojamtangan.com/jamtanganoriginal/Alexandre-Christie 。我想用 - 替换 %20 。我已经尝试了 Stackoverflow 上其他主题的所有代码,但一切都不起作用。

这是我的 htaccess :

RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^brand/([a-z0-9/s]+)$ /brand.php?brand=$1 [L]

我应该修改哪些代码才能实现我的目标?

谢谢

最佳答案

希望这对您有用。

RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /(.*)/(.*)\.php\?cat_type=(.*)&location=(.*)%(.*)\ HTTP
RewriteRule ^ http://your_domain.com/%3/%4/%5-%6? [R=301,L]

RewriteCond %{THE_REQUEST} ^(GET|POST)\ /(.*)/(.*)\.php\?location=(.*)%(.*)\ HTTP
RewriteRule ^ http://your_domain.com/%3/%4-%5? [R=301,L]

关于php - .Htaccess Url 重写将 %20(空格)替换为 "-",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48396086/

相关文章:

php - 将表单中的数据插入表不起作用,不返回错误

php - 如何在不使用提交的情况下从下拉列表中选择值

php - mysql表中的多次插入

php - 如何保存 portlet 位置

mysql - 在 MySQL 查询中重复 COUNT(*) 成本昂贵吗?

php - 如果找不到,我们如何使用 Apache 重定向到新的 HTML 静态内容并回退到旧的基于 CMS 的 PHP 版本? (nginx try_files)

php - 使用php获取文件夹内图像的文件名

php - 为 mySQL 查询转换数组

php - Forbidden 您无权访问/在此服务器上。服务器无法读取 htaccess 文件,为了安全拒绝访问

php - 将所有请求路由到子文件夹 htaccess