Apache 将URL从参数重写到基目录
这是我目前使用的HTACCESS代码,但没有使用: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
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
。在测试此功能之前,请确保清除缓存。谢谢,它确实有效!我不得不做一些编辑,因为我是在一个子目录中使用它,但总的来说,它的工作。