我试图重写我的url,但我收到了一个错误"500内部服务器错误"
我以前从来没有这样做过,我读过一些教程,但我不能说我从中变得更聪明了
.htaccess文件位于根目录(/var/www)中
Options +FollowSymLinks
RewriteEngine On
RewriteBase /sub_domain/directory_to_my_files/
RewriteRule ^([0-9.]+)-([0-9.]+)/(.*)/$ /index.php?pos=$1:$2&text=$3
当前链接如下所示:http://sub_domain.my_domain.com/directory_to_my_files/index.php?pos=(float|integer only):(float| integer only)&text=(任意文本)
但我正在努力做到这一点:http://sub_domain.my_domain.com/directory_to_my_files/(仅限浮点|整数):(仅限浮动|整数)/(任何文本)/
很抱歉,如果链接有点难以阅读。
这应该放在/directory_to_my_files/.htaccess
中
RewriteEngine On
RewriteBase /directory_to_my_files/
RewriteRule ^(-?[0-9.]+)[:-]([0-9.]+)/([^/]+)/?$ index.php?pos=$1:$2&text=$3 [L,QSA,NE]
我已经在本地测试过了:(我不需要重写基础)
RewriteEngine on
RewriteRule ^([0-9.]+)-([0-9.]+)/(.*) /index.php?pos=$1:$2&text=$3 [R,L]
它重定向了我来自
http://loc.domain/555-666/misc-text
至
http://loc.domain/index.php?pos=555:666&text=其他文本
我想这就是你想要的?
关于结尾处的[R,L]:R告诉apache实际重定向,而不仅仅是重写url——这有助于测试。L说这是的最后一条规则
编辑:可能是rewriteBase给你带来了问题吗?试着不用它,看看它是否有效——至少你可以确定问题所在。