Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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/.htaccess/6.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
Apache 将URL从参数重写到基目录_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Apache 将URL从参数重写到基目录

Apache 将URL从参数重写到基目录,apache,.htaccess,mod-rewrite,url-rewriting,Apache,.htaccess,Mod Rewrite,Url Rewriting,这是我目前使用的HTACCESS代码,但没有使用: RewriteEngine On RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA] 我如何才能在以下位置进行: http://www.example.com/index.php?id=100 变成: http://www.example.com/100 您可以在.htaccess文件中使用此选项: RewriteEngine On RewriteRule ^([^/]*)$ /index.php

这是我目前使用的HTACCESS代码,但没有使用:

RewriteEngine On
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]
我如何才能在以下位置进行:

http://www.example.com/index.php?id=100
变成:

http://www.example.com/100

您可以在
.htaccess
文件中使用此选项:

RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?id=$1 [L]

它将给您留下URL:
http://www.example.com/100
。在测试此功能之前,请确保清除缓存。

谢谢,它确实有效!我不得不做一些编辑,因为我是在一个子目录中使用它,但总的来说,它的工作。