首页 文章

友好的timthumb URL与.htaccess

提问于
浏览
0

我目前有以下htaccess

<IfModule mod_rewrite.c>

# redirect all calls to index.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.site.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.site.co.uk/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]

</IfModule>

将非www链接重定向到www,然后在不存在的文件和目录之后将它们发送到索引文件 . 我写了一行应该创建一个使用timthumb的友好URL . 香港专业教育学院尝试了一些变化,并尝试在一些地方,仍然无法让它工作 .

RewriteRule ^ thumb /([^/])/([^/])/([^/] *)$ /_includes/thumb.php?src=images/case/$1&w=$2&h=$3 [L]或RewriteRule ^ thumb /([^/])/([^/])/([^/] *)$ /_includes/thumb.php?src=$1&w=$2&h=$3 [L]

我会赞美任何建议,谢谢 .

2 回答

  • 0

    我认为答案是将图像放在最后,并消除了在图像路径中使用斜杠的可能性 . 还添加了一行来否定对thumb文件夹的请求的index.php重定向:

    <IfModule mod_rewrite.c>
    
    # redirect all calls to index.php
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www.site.co.uk$ [NC]
    RewriteRule ^(.*)$ http://www.site.co.uk/$1 [L,R=301]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
          RewriteCond %{REQUEST_URI} !^/(thumb) [NC]
    RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
          RewriteRule ^thumb/c/(.*)/(.*)/(.*) _includes/thumb.php?src=../images/case/$3&h=$2&w=$1
    
    
    </IfModule>
    

    新的线条进一步缩小

  • 1

    您也可以这样使用: -

    RewriteRule ^thumbnail/([0-9]+)/([0-9]+)/([a-z])/(.*) _includes/timthumb.php?w=$1&h=$2&a=$3&src=$4
    

相关问题