.htaccess 使用重写规则跳过URl中的目录
我有一个web页面,位于服务器的example/files/page.php中。我想使用重写规则跳过URl中的/files目录,以便用户键入example/page.php时能够查看page.php的内容。如何使用重写规则执行此操作?将其添加到网站根目录中的.htaccess中.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
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^(example)/(.*)$ /$1/files/$2 [NC,L]
如果我没有弄错的话,这段代码应该位于/example目录中,对吗?