网上搜到好多解决方案,说在.htaccess配置文件中用RewriteRule方法就可以。
服务器是Linux+Apache
系统自动配置出一个网站301的如下。
rewriterule ^(.*)$ "http\:\/\/www\.xxxxxxx\.com\/$1" [R=301,L] #4bf50a0791089上面这句就是域名你输入的时候加不加www都会自动跳转到www.xxxxxxx.com上。
这个是没有问题的,说明rewriterule这个方法可以用。
但是我配置了一个url静态化的方法可以在服务器上就没有反应。
我的写法是下面这段
RewriteRule ^(.*)/([a-z0-9A-Z]{1,})\.html$ $1/artists.php\?artistid=$1
就是为了实现www.xxxxxxx.com/artists.php?artistid=1转化成www.xxxxxxx.com/1.html
www.xxxxxxx.com/artists.php?artistid=10转化成www.xxxxxxx.com/10.html
请高手帮忙解决,是我写的有问题吗?
服务器是Linux+Apache
系统自动配置出一个网站301的如下。
rewriterule ^(.*)$ "http\:\/\/www\.xxxxxxx\.com\/$1" [R=301,L] #4bf50a0791089上面这句就是域名你输入的时候加不加www都会自动跳转到www.xxxxxxx.com上。
这个是没有问题的,说明rewriterule这个方法可以用。
但是我配置了一个url静态化的方法可以在服务器上就没有反应。
我的写法是下面这段
RewriteRule ^(.*)/([a-z0-9A-Z]{1,})\.html$ $1/artists.php\?artistid=$1
就是为了实现www.xxxxxxx.com/artists.php?artistid=1转化成www.xxxxxxx.com/1.html
www.xxxxxxx.com/artists.php?artistid=10转化成www.xxxxxxx.com/10.html
请高手帮忙解决,是我写的有问题吗?
貌似是这样的。
$2匹配的是([a-z0-9A-Z]{1,})所以应该为
RewriteRule ^(.*)/([a-z0-9A-Z]{1,}).html$ $1/artists.php?artistid=$2
RewriteRule ^(.*)/([a-z0-9A-Z]{2,}).html$ $1/artists.php?artistid=$2
但是不行啊