dsgrs26202 2018-05-07 21:41
浏览 169
已采纳

htaccess URL重写问题重定向到XAMPP上的localhost / c:/

I'm building a new version of a PHP app that has over 180k news items stored in the Database. Many contain hardcoded links in the news.body to the old file structure, which points to something like this people/7768-denis-grabe/ while the new file structure should be single-player.php?id=7768.

I'm really bad with REGEX and have very little understanding of how to work with .htaccess but I've been trying for two days to make a URL Rewrite rule which I think it's almost there but not quite yet.

In my .htaccess I have:

RewriteEngine On  
RewriteRule ^people/([0-9]+)/?$ single-player.php?id=$1 [L]

It's not just rewriting the end of the URL, it's redirecting to the actual file, appending the http://localhost:c/xampp/... which gets me a 403 error forbidden page:

http://localhost/C:/xampp/htdocs/myapp/single-player.php?id=7768

All I need is to get the ID out of that first URL and rewrite it so it would redirect to the same address and just insert the ID as a GET request.

I'm working with XAMPP, mod_rewrite and AllowOverride All are already on

Thank you!

  • 写回答

1条回答 默认 最新

  • dqlhsm9820 2018-05-07 21:54
    关注

    See if maybe this works?

    RewriteRule ^people/([0-9]+).*$ single-player.php?id=$1 [L,NC]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改