首页 > 解决方案 > 带有 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]

谢谢您的帮助!

标签: .htaccessurl-rewriting

解决方案


推荐阅读