我需要使用.htaccess URL重写从URL中获取var1和var2。
URL:
<a href="tmp/image-file-name-var1-var2.jpg">link</a>
htaccess的:
RewriteEngine On
RewriteRule ^tmp/([^\.]+)(here i need help)\.(png|jpg|gif)$ image.php?image=$1.$4&size=$2&position=$3 [NC,L]
结果应该是:
image.php?image=image-file-name.jpg&size=var1&position=var2
答案 0 :(得分:1)
您可以使用此代码:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^tmp/(.+)-([^-]+)-([^.]+)\.(png|jpe?g|gif)$ index.php?image=$1.$4&size=$2&position=$3 [L,QSA,NC]