skip directory in URl by using Rewriting Rules

一世执手 提交于 2019-12-12 06:09:18

问题


I have a web-page with is located in example/files/page.php in my server. I would like to use Rewrite Rules in order to skip the /files directory in the URl so when the user types example/page.php to be able to view the content of the page.php. How is it possible to do so with Rewrite Rules?


回答1:


Add this to the .htaccess in the root directory of your website.

RewriteEngine on

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


来源:https://stackoverflow.com/questions/29036104/skip-directory-in-url-by-using-rewriting-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!