.htaccess - 带有 2 个参数的网址/在 .htaccess 中重写
问题描述
我将我的网站托管在 Godaddy 网络服务器上,我尝试使用 .htaccess 文件重写一些 url,但它不起作用。帮助将不胜感激。
基本上我想替换一个网址,如:
https://www.example.com/photographers/photographer.php?id=1&name=john-doe
在:
https://www.example.com/photographer/1/john-doe
参数1为:id / 参数2为:name
显然我也希望我的服务器以相反的方式在内部重定向。
我尝试了很多组合,但使用重写但没有一个有效。例如我试过:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^photographer/(\d+)/([A-Za-z-]+)/?$ photographers/photographer.php?id=$1&name=$2 [NC,L]
谢谢您的帮助!
解决方案
推荐阅读
- javascript - 单击提交后未执行任何表单操作
- javascript - 使用 for 循环创建动态变量名称和值:JavaScript
- javascript - Electron:使用 IPC(或其他任何东西)共享 DOM 数据(例如发送 img 或 canvas)
- sql - 防止重复使用密钥
- html - 为什么不能更改我自己的 svg 图标的样式
- unity3d - 没有 Ray/Raycast 和 Colliders 的 Unity 鼠标输入
- excel - 具有可变值的数组 - VBA
- assembly - MIPS 快速排序数组
- php - 修复错误编码的 JSON 数据
- javascript - 一个组件的 Angular 事件发射器与另一个组件混淆