Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在这个问题中,有人问是否可以在不访问 php 文件的情况下进行某种类型的 url 重写。(有关更多信息,请参阅问题。)如何访问 php 文件?
您可以将其用于您的 htaccess 文件:
RewriteEngine on RewriteBase / RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php
这只是意味着,将任何不以 js、ico、txt、gif、jpg、png 或 css 结尾的请求重写到您的 index.php 文件中。在 index.php 中,您可以访问任何参数$_SERVER['REQUEST_URI']并根据需要对其进行解析。
$_SERVER['REQUEST_URI']