.htaccess将url更改为查询字符串的一部分,并添加.html扩展名


.htaccess to change url to a part of a querystring and append with .html extention

我正在尝试更改以下URL:

   http://localhost/app/site/?page=12&module=custom&title=Swat_Medical_College-_The_Project_of_Swat_Medical_Complex

到这个URL:

   http://localhost/app/site/12/custom/Swat_Medical_College-_The_Project_of_Swat_Medical_Complex.html

我已经尝试了太多的选项,使其功能,但徒劳的…

 RewriteEngine On
 RewriteRule ^/('d+)/([a-z-]+) index.php?page=$1&module=$2&title=$3 [L]

抛出404错误页面未找到…请提前帮我解决以上url转换问题,谢谢。也请如果有任何简单和基本的教程关于url重写,我将真的非常感激。由于

这可能是您正在寻找的规则:

RewriteEngine on
RewriteRule ^/app/site/('d+)/([a-z-]+)/(.+)'.html$ /app/site/index.php?page=$1&module=$2&title=$3 [L,B]

这将做你在你的问题中概述。但我不确定这是否真的是你的情况。但你可能会根据自己的需要进行调整。

要了解详细信息,我只能建议您查看Apache重写模块的官方文档,正如上面的评论中提到的那样。是的,这是非常技术性的。但它也写得很好,非常精确,并且有很好的例子。