我有一个名为URL www.example.com/print?id=adder
我希望它看起来像www.example.com/print/adder
.htaccess中的脏网址没有转化成干净的URL
我使用下面的代码.htacces
RewriteEngine on
# redirect all requests except only POST
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} \s/+(.*?/)?(?:index)?(.*?)\.(?:php?)[\s?/] [NC]
RewriteRule^/%1%2 [R=302,L,NE]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule^- [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteRule ^print/([a-z]+) print.php?id=$1 [NC,L]
但仍然,我有像www.example.com/print?id=adder
这样的网址。我正在使用wamp 3.0.6(Latest Version)
,PHP 7.0,10
& Apache 2.4.23
。为什么我面临这个问题。为什么不是代码工作?
是/打印文件夹htaccess的? – starkeen
不,我的.htaccess位于根文件夹中,并且print不是它的'print.php'文件夹。我已将.php扩展名隐藏起来,因此您可以看到'print?id ='而不是'print.php?id =' –
“但是,我的网址类似于...” - 您还需要更改你的应用程序中的URL(这实际上是_changes_的URL) - 大概你已经这样做了? – MrWhite