【发布时间】: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