删除所有php扩展并删除url中的变量
我得到了这个url删除所有php扩展并删除url中的变量,php,url,mod-rewrite,url-rewriting,get,Php,Url,Mod Rewrite,Url Rewriting,Get,我得到了这个url /localhost/andalucia/productdetails.php?value=20 我想把它改成 /localhost/andalucia/productdetails/20 如何做到这一点,以及如何在处理程序页面中获得值20? 我应该更改编码还是只添加一个ht访问文件? 如果要添加ht访问文件,其中应包含哪些代码? 如果我有更多的页面,比如: /localhost/andalucia/product /localhost/andalucia/home /l
/localhost/andalucia/productdetails.php?value=20
我想把它改成/localhost/andalucia/productdetails/20
如何做到这一点,以及如何在处理程序页面中获得值20?我应该更改编码还是只添加一个ht访问文件?
如果要添加ht访问文件,其中应包含哪些代码?
如果我有更多的页面,比如:
/localhost/andalucia/product
/localhost/andalucia/home
/localhost/andalucia/contactus
它们也会自动受到影响吗?好的,我试着用
RewriteRule ^productdetails/([0-9]+)$ productdetails.php?value=$1 [L,QSA]
但是现在的问题是,我所有的图片都在html中消失了,我无法打开另一个页面
/localhost/andalucia/product
/localhost/andalucia/home
/localhost/andalucia/contactus
我需要一个htaccess代码,可以打开所有这些
/localhost/andalucia/product
/localhost/andalucia/home
/localhost/andalucia/contactus
/localhost/andalucia/productdetails/20
请帮助某人使用apache扩展
mod_rewrite
将漂亮的URL转换为脚本所需的URL非常容易。这个.htaccess
示例是您放在web根目录中的,它应该可以帮助您:
RewriteEngine On
RewriteRule ^andalucia/productdetails/([0-9]+)$ /andalucia/productdetails.php?value=$1 [L]
此示例将只重写andalucia/productdetails/NNNN…
格式化URL,所有其他URL将不受影响。如果需要传递其他查询参数,如/andalucia/productdetails/20?sort=asc
,则需要将QSA
标志(查询字符串附加)传递给重写规则:
RewriteRule ^andalucia/productdetails/([0-9]+)$ /andalucia/productdetails.php?value=$1 [QSA,L]
L
标志将禁止评估下一个规则。只需查阅mod_rewrite
文档进行深入讨论 您可以使用htaccess来实现这一点。谷歌为重写规则可能的副本检查此副本为您的问题。。我复制粘贴删除安达卢西亚在重写规则中仍然没有找到对象我帮不上忙