【问题标题】:Removing index.php from subdomain从子域中删除 index.php
【发布时间】:2015-11-07 17:49:16
【问题描述】:

我的子域中有以下 .htaccess 文件。 我的网站有http://hello/forum/index.php,并且想隐藏这个index.php 文件,并使其成为http://hello/forum

每当我使用附加的.htaccess 时,它都会指向http://hello,而不是http://hello/forum。我错过了什么吗?

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) forum/$1$2 [R=301,NE,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ forum/index.php/$1 [L]
</IfModule>

【问题讨论】:

    标签: .htaccess mod-rewrite url-rewriting friendly-url


    【解决方案1】:

    试试这些规则:

    RewriteCond %{THE_REQUEST} ^GET\ /(forum)/index\.php [NC]
    RewriteRule ^ /%1 [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /forum/index.php/$1 [L]
    

    【讨论】:

    • 很遗憾,它不起作用...我还需要检查 hello 的 htaccess 文件吗?
    【解决方案2】:

    我可以通过添加来解决这个问题

    DirectoryIndex index.php index.html
    

    在 .htaccess 文件中。

    【讨论】:

      猜你喜欢
      • 2017-09-20
      • 2016-01-16
      • 1970-01-01
      • 2019-11-30
      • 1970-01-01
      • 2016-08-20
      • 1970-01-01
      • 2017-06-01
      • 2011-09-10
      相关资源
      最近更新 更多