我知道这个问题被问了很多次,但我没有得到适当的解决方案,我的状况可能是因为缺乏有关此代码的知识。删除php文件扩展名以及在目录格式有_GET参数
到目前为止,我使用下面的代码隐藏PHP文件的扩展名:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
,当我浏览过像这样的网址:http://example.com/solutions
为http://example.com/solutions.php
它的工作原理相当不错。
但是,当我想使用的网址与_GET
这样的:http://example.com/solutions/page_slug
其中page_slug
是_GET
PARAM说?slug=page_slug
...然后在那个时候产生404
没有发现error
,因为它正在考虑page_slug作为solutions目录中的文件。
所以我想它应该把第一个参数中的URL作为文件名,然后最多两个PARAM,例如得到PARAM:http://example.com/solutions_file/param1_page_slug/param2_any_other_param_may_be_id
如果有两个以上的PARAM然后链接结构将是正常的例如,如果URL是这样的:
http://example.com/solutions_file/param1_page_slug/param2_any_other_param_may_be_id/param3_this_is_extra
这样的话我们的URL结构是这样的:
http://example.com/solutions_file?param1=page_slug¶m2=any_other_param_may_be_id¶m3=this_is_extra¶m4=and_so_on
所以这就是我正在努力实现的目标,我如何实现这一目标?
感谢这个工作,超过3 PARAM我可以手动通过查询字符串。非常感谢 :) – 2015-04-06 08:02:43