【问题标题】:Url Rewriting for Static Files静态文件的 URL 重写
【发布时间】:2014-09-19 07:02:32
【问题描述】:

我想要 url 重写。我正在制作一个脚本并从根文件夹中分离其他静态页面,如 register.php , login .php 我把它放在一个名为 root_files 的子文件夹中

所以 login.php 和其他静态文件位于 mydomain.com/root_files/login.php 中,我不希望公众看到该文件夹​​。所以我编写了稍微隐藏网址的编码

此编码位于网站的 index.php 文件中的其他文件中

if(isset($_GET["page"]) && $_GET["page"]=='login')
{
 include'root_files/login.php';
 die();
}

因此,当有人打开 mydomain.com/index.php?page=login 时,它会显示 mydomain.com/root_files/login.php 中存在的文件

而且我不知道 .htaccess 编码。

所以我想在打开 mydomain.com/login 时对重写 url 进行编码,它会显示 mydomain.com/root_files/login.php 等其他静态页面(如注册等)中存在的文件。

【问题讨论】:

  • 您好,我得到了这个代码它正在工作但是当我使用 mydomain.com/root_files 时,它也会将其重写为 mydomain.com/root_files/?page=root_files RewriteEngine On RewriteRule ^page/([^/]*)/$ /index.php?page=$1 [L]

标签: php


【解决方案1】:

呵呵,我得到了解决方案的代码

RewriteEngine On
RewriteRule ^page/([^/]*)/$ /index.php?page=$1 [L] 
RewriteCond %{REQUEST_URI} !^/forum$

【讨论】:

    猜你喜欢
    • 2012-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-19
    • 1970-01-01
    • 2012-11-26
    相关资源
    最近更新 更多