Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除所有php扩展并删除url中的变量_Php_Url_Mod Rewrite_Url Rewriting_Get - Fatal编程技术网

删除所有php扩展并删除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

我得到了这个url

/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来实现这一点。谷歌为重写规则可能的副本检查此副本为您的问题。。我复制粘贴删除安达卢西亚在重写规则中仍然没有找到对象我帮不上忙