【问题标题】:Change htaccess Joomla to work with CI in subfolder更改 htaccess Joomla 以在子文件夹中使用 CI
【发布时间】:2013-01-29 09:46:19
【问题描述】:

目前我有一个运行 joomla 1.5 的主站点和一个在 Codeignter 上制作的附加应用程序的子文件夹。

当我打开应用程序索引目录 url - www.mysite.com/app - 没关系,但如果我尝试更深入地使用应用程序,例如 www.mysite.com/app/controller/view - 我会得到传统的 joomla 404 页面.

问题是 joomla .htaccess 中的规则适用于指向服务器上真实文件夹的任何 url - 仅在一个级别上,但我如何才能使其 NOT_WORK 用于真实子文件夹中的 joomla。

当前 joomla htaccess 是:

Options +FollowSymLinks
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#

【问题讨论】:

  • 您是否也在使用app 文件夹中的htaccess 文件?如果是这样,你能包括其中的内容吗?

标签: .htaccess codeigniter joomla url-rewriting url-routing


【解决方案1】:

您可以将RewriteCond %{REQUEST_URI} !^/app 添加到您的 .htaccess 文件中。

所以它看起来像这样:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} !^/app
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

您还必须将这样的 .htaccess 文件添加到您的应用文件夹中:

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

【讨论】:

    猜你喜欢
    • 2013-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-17
    • 2020-07-13
    • 2011-08-23
    • 2013-05-29
    • 1970-01-01
    相关资源
    最近更新 更多