2018-05-07 21:41
浏览 149

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:


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!

图片转代码服务由CSDN问答提供 功能建议

我正在构建一个新版本的PHP应用程序,该数据库中存储了超过180k个新闻项目。 许多包含news.body中的硬编码链接到旧文件结构,指向类似 people / 7768-denis-grabe / 的内容,而新文件结构应该是单播放器。 php?id = 7768

我对REGEX非常不满意,对如何使用.htaccess知之甚少,但我已经尝试了两天 制作一个URL重写规则,我认为它几乎存在但尚未完成。


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

这不仅仅是重写 在URL的末尾,它重定向到实际文件,附加 http:// localhost:c / xampp / ... ,这会给我一个403错误的禁止页面: \ n

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

所有我 需要的是从第一个URL中获取ID并重写它,以便它将重定向到相同的地址并插入 ID作为GET请求。

我正在使用XAMPP, mod_rewrite AllowOverride All 已经在 \ n


  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dqlhsm9820 2018-05-07 21:54

    See if maybe this works?

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

    解决 无用
    打赏 举报

相关推荐 更多相似问题