[英]how to hide a url from address bar using .htacess
我一直在互联网上搜索这个,但是我没有运气。 我找到了一些答案,但没有帮助
我不怎么使用.htacess但我发现了这段代码
RewriteEngine on
# Rewrite /foo/bar to /foo/bar.php
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
# Return 404 if original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
# NOTE! FOR APACHE ON WINDOWS: Add [NC] to RewriteCond like this:
# RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$" [NC]
它似乎阻塞了除索引之外的所有页面
http://www.skymount.in/mega_menu.php?id=%27503732-u_submenuid%27
这是我希望它看起来像的链接
http://www.skymount.in/mega_menu.php
或者可能
http://www.skymount.in/mega_menu
请帮忙
$ 1的意思是“使用原始url的第一个捕获部分”。 为了捕获原始URL的一部分,您需要使用括号将其捕获。像这样:
RewriteRule ^/mega_menu/(.*) /$1
这意味着“采用以/ mega_menu /开头的任何东西,然后捕获之后的内容,并将其放入变量$ 1中。仅重写$ 1变量并附加原始查询字符串。
希望对您有帮助!
将此用作整个.htaccess
文件内容:
RewriteEngine on
RewriteRule ^mega_menu\.php$ mega_menu.php?id=%27503732-u_submenuid%27 [NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.