Apache 的 .htaccess 重写规则[短网址]
问题描述:
我想让
localhost/ey3i
跳转到
localhost/responseShortUrl.php?url=ey3i
怎么写.htaccess
[其中,ey3i是随机的4到7位大小写字母和数字]
在网上搜到一份
RewriteEngine On RewriteBase /
RewriteRule ^/(.*)$
responseShortUrl.php?url=$1[L]
但是不行,用不了
求大神指点
答
RewriteEngine On
RewriteRule ^(\w{4})$ responseShortUrl.php?url=$1 [L,NC]
答
你的语句的行是怎么分的?
试一下
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ responseShortUrl.php?url=$1[L]