[英]How to hide query string from url using .htaccess?
Here is the link for editing a form : 这是用于编辑表单的链接:
<a class="btn btn-success btn-xs" href="<?php echo SITE_URL."update?z=$zone_id" ?>" >Edit</a>
Now in update.php page the url is something like bellow : 现在在update.php页面中,URL如下所示:
http://localhost/aponit/dev/update?z=55
Now I want to url should like like bellow : 现在我想要的URL应该像下面这样:
http://localhost/aponit/dev/update/55
How can I do this using .htaccess ? 我如何使用.htaccess做到这一点?
Note: Using current .htaccess rule I am hiding just .php
extension from the url 注意:使用当前的.htaccess规则,我仅从URL隐藏
.php
扩展名
My Current .htaccess file 我当前的.htaccess文件
ErrorDocument 404 /not-found.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteRule ^aponit/dev/update/([0-9]+) aponit/dev/update.php?z=$1 [L]
Try this: Change your link: 尝试以下操作:更改链接:
<a href="http://localhost/aponit/dev/update/<?php echo $zone_id ?>" >Edit</a>
Update your .htaccess
with code: 使用代码更新
.htaccess
:
RewriteEngine on
RewriteRule ^aponit/dev/update/([0-9]+) aponit/dev/update.php?z=$1 [L]
Hope helpful for you :) 希望对您有所帮助:)
Updated .htaccess : 更新的.htaccess:
ErrorDocument 404 /not-found.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteRule ^aponit/dev/update/([0-9]+) aponit/dev/update.php?z=$1 [L]
Try using this rule in your .htaccess
. 尝试在
.htaccess
使用此规则。 Before you do, make sure your browser cache has been cleared and the rule is placed at the top of your .htaccess
. 在执行此操作之前,请确保已清除浏览器缓存并将规则放在
.htaccess
的顶部。
RewriteEngine On
RewriteRule ^aponit/dev/update/([^/]*)$ /aponit/dev/update?z=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.