2

我有一个使用 Codeigniter 和 SLIR(Smart Lencioni Image Resizer https://github.com/lencioni/SLIR)的应用程序。SLIR 允许您使用直观的 URI 结构调整图像大小。例如:

<img src="/slir/w100-h100/path/to/image.jpg"/>

这将调整图像大小以适合 100px * 100px。无论出于何种原因,当我尝试查看调整大小的图像时(例如http://a2op03.com/slir/w300-h90/images/content/franchise-opportunities-badge.png)我收到由 Codeigniter 生成的 404 错误. 我已经验证了以下内容:

Codeigniter [root] htaccess 文件如下所示:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

/slir/ 中的 htaccess 文件如下所示:

# Prevent other scripts from interfering with SLIR
php_value auto_prepend_file none
php_value auto_append_file none

# Pretty URLs
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=40]
RewriteRule . index.php [L]
</IfModule>

# Prevent viewing of the error log file in its default location
<Files slir-error-log>
Order Deny,Allow
Deny from All
</Files>

我最初的怀疑是 mod_rewrite.c 没有正确设置,因此没有被 SLIR htaccess 处理并退回到将其发送到 404 的根 htaccess 上。我通过 servint.net 托管在托管 VPS 和拥有对服务器的完全访问权限的 WHM。主持人声称 mod_rerwrite 应该可以正常工作。我在另一台服务器上完美地运行了这个,但我不知道为什么它在这里不起作用。任何帮助表示赞赏!

4

1 回答 1

2

我想到了!我只需要添加

RewriteBase /slir/

RewriteEngine On

在 SLIR 的 htaccess 文件中!

于 2013-01-29T16:22:54.643 回答