【问题标题】:.htaccess not working in centos web panel.htaccess 在centos web 面板中不起作用
【发布时间】:2016-12-31 13:48:20
【问题描述】:

mod_rewrite 已启用

vhosts.conf 设置为允许

<Directory "/home/chinatow/public_html">
        AllowOverride All
</Directory> 

.htaccess(应该没问题)

#--- Uncomment this line for production or testing server
#SetEnv CI_ENV production

#--- Allow remote API access; change "*" to "your-domain.com" for better security
#--- Note: require Headers mod enabled (sudo a2enmod headers)
#Header add Access-Control-Allow-Origin "*"

#--- URL rewrite
#--- Note: require Headers mod enabled (sudo a2enmod rewrite)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

我想一切正常,但最终 .htaccess 无法正常工作。

【问题讨论】:

    标签: .htaccess codeigniter centos


    【解决方案1】:

    您可以使用这个 .htaccess 文件。

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

    【讨论】:

      【解决方案2】:

      试试这个

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

      【讨论】:

        【解决方案3】:

        原来是 htaccess 错误。我的网址是

        xx.xx.xx.xx/~账号

        htaccess 应该是

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

        谢谢!

        【讨论】:

          【解决方案4】:

          这可能会对你有所帮助。

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

          【讨论】:

            猜你喜欢
            • 2019-05-15
            • 2014-01-09
            • 2020-03-19
            • 1970-01-01
            • 1970-01-01
            • 2018-08-07
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多