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]

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

报告相同问题?