dsgrs26202
dsgrs26202
2018-05-07 21:41

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 dqlhsm9820 3年前

    See if maybe this works?

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

    点赞 评论 复制链接分享