Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.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
.htaccess 使用类别名称的HTACCESS重写URL_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

.htaccess 使用类别名称的HTACCESS重写URL

.htaccess 使用类别名称的HTACCESS重写URL,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我想用htaccess重写URL。。。用于转换以下URL 到 我不想在url中写分类,我使用下面的代码,但没有用 RewriteRule ^(.*)/ category.php?id=$1 RewriteRule ^(.*) category.php?id=$1 您需要使用RewriteCond来操作查询字符串 RewriteEngine on RewriteCond %{THE_REQUEST} /category\.php\?id=([^\s&]+) [NC

我想用htaccess重写URL。。。用于转换以下URL

我不想在url中写分类,我使用下面的代码,但没有用

RewriteRule ^(.*)/ category.php?id=$1
RewriteRule ^(.*) category.php?id=$1    

您需要使用RewriteCond来操作查询字符串

RewriteEngine on


RewriteCond %{THE_REQUEST} /category\.php\?id=([^\s&]+) [NC]
RewriteRule ^ /%1? [NE,L,R]

您需要使用RewriteCond来操作查询字符串

RewriteEngine on


RewriteCond %{THE_REQUEST} /category\.php\?id=([^\s&]+) [NC]
RewriteRule ^ /%1? [NE,L,R]