【发布时间】:2014-10-16 22:22:53
【问题描述】:
我正在创建一个网站,在将网站上传到虚拟主机之前,我在 Windows 上使用 XAMPP。我试图使用搜索引擎友好的 URL,例如:
http://localhost/mysite/[something]
to
http://localhost/mysite/index.php?p=[something]
我试过这个.htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([0-9A-Za-z]+) index.php?id=$1 [QSA,L] #and also tried http://localhost/mysite/index.php?p=$1
在此之前,我尝试了更多示例,但没有奏效。真正的问题是,例如,如果 y 类型
localhost/mysite/some_page
我收到一个错误 (403),使用 [R] 标志我意识到重定向是:http://localhost/C:/XAMPP/htdocs/mysite/index.php?p=some_page
我删除了 htaccess 文件并重新启动了 apache,但问题仍然存在一些 url
【问题讨论】:
-
^([0-9A-Za-z]+)不会匹配/mysite/something。尝试将其简化为^(.*)$,看看会发生什么。
标签: php windows apache redirect xampp