Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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
Html 在href URL中隐藏页面文件名_Html_.htaccess_Href - Fatal编程技术网

Html 在href URL中隐藏页面文件名

Html 在href URL中隐藏页面文件名,html,.htaccess,href,Html,.htaccess,Href,我在apachehtdocs的根文件夹中配置了htaccess文件,如 DirectoryIndex index.py 当您打开此页面时,会看到href: <h3><a href='/?id=blah'><font color='8650AC'>blah</font></a></h3> 而不是 http://127.0.0.1/?id=blah 如我所愿。如何解决此问题?尝试在同一行中添加此行。htaccess: D

我在apachehtdocs的根文件夹中配置了htaccess文件,如

DirectoryIndex index.py
当您打开此页面时,会看到href:

<h3><a href='/?id=blah'><font color='8650AC'>blah</font></a></h3>
而不是

http://127.0.0.1/?id=blah 

如我所愿。如何解决此问题?

尝试在同一行中添加此行。htaccess:

DirectoryIndex index.py

RewriteEngine On

# remove index.php
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} /index\.py [NC]
RewriteRule ^(.*?)index\.py$ /$1 [L,R=302,NC,NE]

你能给我解释一下这个神秘的正则表达式背后的魔力吗?哦,它并不神秘。使用
%{THE_REQUEST}
我们确保
index.py
出现在输入的URL中,并且
(.*)index\.py
正则表达式用于捕获出现在
index.py
之前的URI。这个捕获的字符串用作替换。因此,当我们在请求的地址中看到/index.py时,我们会查找它之前的请求中的内容,并只保留它或什么?是的,此规则还会将
/sub/index.py
重定向到
/sub/
,它不会破坏post请求吗?因为当我拿到表格时,一切都很好,但是用post的话,它就有点不起作用了。为什么?
DirectoryIndex index.py

RewriteEngine On

# remove index.php
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} /index\.py [NC]
RewriteRule ^(.*?)index\.py$ /$1 [L,R=302,NC,NE]