在.htaccess中具有2个参数/重写的URL

时间:2018-06-11 20:11:28

标签: .htaccess url-rewriting

我在godaddy网络服务器上托管我的网站,我尝试使用.htaccess文件重写一些网址,但它不起作用。非常感谢帮助。

基本上我想替换像:

这样的网址

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]

感谢您的帮助!

0 个答案:

没有答案
相关问题