Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
.htaccess 使用重写规则跳过URl中的目录_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess 使用重写规则跳过URl中的目录

.htaccess 使用重写规则跳过URl中的目录,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我有一个web页面,位于服务器的example/files/page.php中。我想使用重写规则跳过URl中的/files目录,以便用户键入example/page.php时能够查看page.php的内容。如何使用重写规则执行此操作?将其添加到网站根目录中的.htaccess中 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d # not a dir RewriteCond %{REQUEST_FILENAME} !-f # not a

我有一个web页面,位于服务器的example/files/page.php中。我想使用重写规则跳过URl中的/files目录,以便用户键入example/page.php时能够查看page.php的内容。如何使用重写规则执行此操作?

将其添加到网站根目录中的.htaccess中

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^(example)/(.*)$ /$1/files/$2 [NC,L]

如果我没有弄错的话,这段代码应该位于/example目录中,对吗?