【问题标题】:.htaccess URL rewrite rules folder.htaccess URL 重写规则文件夹
【发布时间】:2017-07-16 18:47:08
【问题描述】:

我的 html 文件夹中有这个

--html
  --.htaccess
  --app
      --application_name
        --public
          --index.php
  --landing_page
    --index.php

截至目前,每次访问网站url(www.website.com)时,浏览器都会打开landing_page/index.php。

我怎样才能在访问 www.website.com/beta 时,向 html/app/application_name/public/index.php 发出请求

我已尝试将其添加到 .htaccess 中

RewriteRule ^beta/?$ app/application_name/public/index.php [L,NC]

这是整个.htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^beta/?$ app/application_name/public/index.php [L,NC]

但它不起作用。不知道用什么词来搜索这类问题。

【问题讨论】:

    标签: php .htaccess


    【解决方案1】:

    您的根目录当前设置为 /html,因此 RewriteBase / 位于 //beta/ 根本不存在。您可以更改RewriteBase /app/application_home/public/ 并设置RewriteRule ^beta/?$ index.php [L,NC]。但是,这不再允许您访问登录页面,不确定这是否是您想要的?

    【讨论】:

    • 我仍然需要登陆页面
    • 然后在/app/application_home/public/目录下创建一个单独的.htaccess,使用RewriteBase /app/application_home/public/,重写规则为RewriteRule ^beta/?$ index.php [L,NC]
    • 什么是完整的.htaccess?
    • 完整的 .htacess 与您的 .htaccess 类似,只需更改我提到的那些行,但放入您想要重写的目录中
    猜你喜欢
    • 2012-08-20
    • 2016-03-30
    • 1970-01-01
    • 2012-11-22
    • 1970-01-01
    • 2014-12-20
    • 2012-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多