【问题标题】:.htaccess isn't loading static html pages in additional domain.htaccess 没有在其他域中加载静态 html 页面
【发布时间】:2013-07-29 18:21:21
【问题描述】:

在我的附加域 example-domain.com 中浏览普通 html 页面时遇到问题

这是我的文件结构

public_html
        -css
        -img  
        -js
        example-domain.com              <- get server error
                          - index.html    
                          -products.html   
                          - contact.html
        -system
         .htaccess  
         index.php

我在主站点中使用 codeigniter 框架,在附加域中使用简单的 html example-domain.com ,当我将 url 用于浏览 example-domain.com 时,我收到 500 内部服务器错误,我认为这是由于我的 .htaccess 文件用于主域。如何修改它以在我的附加域中加载简单的 .html 文件。

我的 .htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|img|css|js|uploads|robots\.txt|sitemap\.xml)
RewriteRule ^(.*)$ index.php/$1 [L]

【问题讨论】:

  • 只需将|exampledomain\.com 添加到RewriteCond 部分即可。
  • @HashemQolami 非常感谢!

标签: .htaccess codeigniter url


【解决方案1】:

目前,我所看到的,如果请求的 URL 不是文件而不是目录,则您正在尝试进行重定向。可以使用这些指令来完成:

RewriteEngine On
Options -MultiViews

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

【讨论】:

  • 请详细说明不正确之处。我对我的所有 codeigniter 站点都使用相同的 RewriteCondRewriteRule 语句,并且从未遇到过问题。
  • 如果您有兴趣,这是一个非常简单的解释为什么 $1 在RewriteCond 中有效。 webmasterworld.com/apache/4330396.htm
  • @Jeemusu 非常有趣。一旦我尝试在 .htaccess 中使用前向引用,但它们不起作用。我决定,它是不可能使用的。谢谢,我从我的回答中删除了不正确的陈述。
【解决方案2】:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-15
    • 2017-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-22
    相关资源
    最近更新 更多