我目前有以下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]
我会赞美任何建议,谢谢你。
答案 0 :(得分:1)
我认为答案是将图像放在最后,并消除了在图像路径中使用斜杠的可能性。还添加了一行来否定对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 :(得分:0)
您也可以这样使用: -
RewriteRule ^thumbnail/([0-9]+)/([0-9]+)/([a-z])/(.*) _includes/timthumb.php?w=$1&h=$2&a=$3&src=$4