【问题标题】:CodeIgniter3 HMVC Routing with .htaccess not workingCodeIgniter3 HMVC 路由与.htaccess 不工作
【发布时间】:2016-06-01 20:45:26
【问题描述】:

我是 CI3 的新手,我花了一个多星期的时间让 CodeIgniter3 HMVC WireDesignz Routing 与 .htaccess 一起工作,但它仍然无法正常工作。

因为有多个来源可能导致错误,我写给你我的GitHub Repository的链接https://github.com/ibudisteanu/PHP-TESTS

行为超级简单:我可以毫无错误地访问以下地址

我在我的路由中获得以下链接的回报:

我得到的错误是Not Found The requested URL /login was not found on this server.

【问题讨论】:

标签: routing routes codeigniter-3 codeigniter-hmvc


【解决方案1】:

这就是我对你的 htaccess 文件所做的一切,它在我的测试服务器上工作正常

Options +FollowSymLinks -Indexes
RewriteEngine on

# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
#RewriteBase /wherever/ci/is

# RewriteBase /

# Restrict your site to only one domain
# Important USE ONLY ONE OF THESE OPTIONS BELOW!

# Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#RewriteCond %{HTTP_HOST} (.+)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

# Option 3: Remove index.php from URL
#RewriteCond %{HTTP:X-Requested-With}    !^XMLHttpRequest$
#RewriteCond %{THE_REQUEST}                ^[^/]*/index\.php [NC]
#RewriteRule ^index\.php(.*)$            $1 [R=301,NS,L]

# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#RewriteCond $1 !^(index\.php|public_html|\.txt|robots\.txt|favicon\.ico|style\.css)

# deal with php5-cgi first
<IfModule mod_fcgid.c>
    RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>

<IfModule !mod_fcgid.c>

    # for normal Apache installations
    <IfModule mod_php5.c>
        RewriteRule ^(.*)$ index.php/$1 [QSA,L]
    </IfModule>

    # for Apache FCGI installations
    <IfModule !mod_php5.c>
        RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
    </IfModule>

</IfModule>

我刚刚评论了RewriteBase /

我不明白 RewriteBase 做了什么,所以我的回答可能是错误的。

这是我与 HMVC 一起使用的 .htaccess,我没有问题。

    RewriteEngine on
Options -Indexes

RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

【讨论】:

    【解决方案2】:

    我在 My HMVC CI3 中的 .htaccess 中使用以下代码...它在实时服务器和本地主机上运行良好-

    <IfModule mod_rewrite.c>
    RewriteEngine On
    Options -Indexes
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-22
      • 1970-01-01
      • 2014-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多