【问题标题】:htaccess in sub-folder in code-igniter project does not work for live server but works in localhostcode-igniter 项目中子文件夹中的 htaccess 不适用于实时服务器,但适用于 localhost
【发布时间】:2015-11-21 01:53:38
【问题描述】:

我的网站有两个目录。

www.mydomain.com 的根目录和一个名为“worker”的子文件夹 我的站点中有两个 htacess 文件,一个是根目录:

wwww.www.mydomain.com:
 -htaccess
another is in 
wwww.www.mydomain.com/worker
 - htaccess

根目录htaccess代码:

Options +FollowSymlinks
Options -Indexes
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
 Order deny,allow
 Deny from all
</FilesMatch>

RewriteEngine On
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^system/download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

“worker”子目录htaccess的代码:

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

我的根目录和“worker”文件夹基于 codeigniter ... 最初我不得不使用"localhost/index.php/worker" 来访问工作子文件夹。当我使用重写从 url 中删除 index.php 时,URI 重写在 localhost 中工作,我可以使用 "localhost/worker" 在 localhost 中看到工作文件夹 但在实时服务器上,"wwww.mydomain.com/worker" url 出现 404 错误。

请有人解决它,以便我可以使用 url "wwww.mydomain.com/worker" 在实时服务器中查看子文件夹。 注意:我的主机是基于linux的,运行Apache服务器。

问候 扎希德

【问题讨论】:

  • 在第二个 htaccess 中,最后一行,尝试写: RewriteRule ^(.*)$ index.php?/$1 [L] - 注意 '?' .php 扩展名后的问号 - 救了我(和其他一些人)几次... :)

标签: php .htaccess codeigniter mod-rewrite url-rewriting


【解决方案1】:

您必须检查实时服务器上的权限,它应该是755 not 777,因为有时在 777 上它不起作用..所以请检查 htaccess 文件的权限

【讨论】:

  • 通常,文件有 644 个权限。你是说目录权限吗?
猜你喜欢
  • 2012-06-14
  • 2014-04-03
  • 1970-01-01
  • 2020-09-03
  • 2012-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-30
  • 2017-01-30
相关资源
最近更新 更多