Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess重写规则,正则表达式不起作用,返回404_Php_.htaccess_Url Rewriting - Fatal编程技术网

Php .htaccess重写规则,正则表达式不起作用,返回404

Php .htaccess重写规则,正则表达式不起作用,返回404,php,.htaccess,url-rewriting,Php,.htaccess,Url Rewriting,我尝试使用timthumb库调整图像大小。 我可以通过以下URL直接使用它 http://localhost/study/server/resize/thumb.php?src=http://localhost/study/server/product/1/1/orig-1.jpg&w=160&h=130 而且效果很好 但是当我像这样重写我的url时 http://localhost/study/server/resize/160x130/r/product/1/1/orig-1.jpg 加

我尝试使用timthumb库调整图像大小。
我可以通过以下URL直接使用它

http://localhost/study/server/resize/thumb.php?src=http://localhost/study/server/product/1/1/orig-1.jpg&w=160&h=130

而且效果很好

但是当我像这样重写我的url时

http://localhost/study/server/resize/160x130/r/product/1/1/orig-1.jpg

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(resize) [NC]
    RewriteRule ^resize/(.*)x(.*)/r/(.*) resize/thumb.php?src=http://localhost/study/server/$3&h=$2&w=$1&c=1
</IfModule>

重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_URI}^/(调整大小)[NC]
重写规则^resize/(*)x(.*)/r/(.*)resize/thumb.php?src=http://localhost/study/server/$3&h=$2&w=$1&c=1

不幸的是,此规则返回404错误

使用此
重写规则

RewriteRule ^study/server/resize/([0-9]+)x([0-9]+)/r/product/([0-9]+)/([0-9]+)/(.*)$ 
/study/server/resize/thumb.php?src=/study/server/product/$3/$4/$5&w=$1&h=$2 [L]
组1匹配宽度、零位或多位数字
第2组匹配高度、零位数或更多位数
第3组匹配/product/之后的第一个数字,一个数字,您可以根据需要修改
第4组匹配/product/之后的第二个数字,一个数字,您可以根据需要修改
组5与文件名匹配

这种情况

RewriteCond %{REQUEST_URI} !^/(resize) [NC]

不需要

您可以使用什么服务器wamp或xammp…?ubuntu apache2 httpd