Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/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 Htaccess仅适用于友好URL_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php Htaccess仅适用于友好URL

Php Htaccess仅适用于友好URL,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,如何仅为友好URL重写htaccess? 我有 我只想重定向像/products/1这样的URL,但它也适用于/show\u a\u product.php?product\u id=1您可以使用另一个规则来阻止/show\u a\u product.php?product\u id=1URI: RewriteEngine On RewriteCond %{THE_REQUEST} /show_a_product\.php[?/\s] [NC] RewriteRule ^ - [L,R=404

如何仅为友好URL重写htaccess? 我有


我只想重定向
/products/1
这样的URL,但它也适用于
/show\u a\u product.php?product\u id=1
您可以使用另一个规则来阻止
/show\u a\u product.php?product\u id=1
URI:

RewriteEngine On

RewriteCond %{THE_REQUEST} /show_a_product\.php[?/\s] [NC]
RewriteRule ^ - [L,R=404]

RewriteRule ^products/(\d+)/?$ show_a_product.php?product_id=$1 [QSA,NC,L]

但当用户键入类似于
show_a_product.php
的内容时,它仍然可以工作,我认为这应该返回404页,而不是禁止页面。
RewriteEngine On

RewriteCond %{THE_REQUEST} /show_a_product\.php[?/\s] [NC]
RewriteRule ^ - [L,R=404]

RewriteRule ^products/(\d+)/?$ show_a_product.php?product_id=$1 [QSA,NC,L]