简体   繁体   English

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

[英]htaccess URL Rewriting issue redirecting to localhost/c:/ on XAMPP

I'm building a new version of a PHP app that has over 180k news items stored in the Database. 我正在构建一个新版本的PHP应用程序,该应用程序在数据库中存储了超过18万条新闻。 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 . 许多文件在news.body中都包含指向旧文件结构的硬编码链接,该链接指向诸如people/7768-denis-grabe/之类的文件,而新文件结构应为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. 我对REGEX真的很不好,对.htaccess的使用方法了解甚少,但是我已经尝试了两天时间来制定URL重写规则,我认为它几乎已经存在,但还没有。

In my .htaccess I have: 在我的.htaccess文件中,我有:

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: 它不只是重写URL的末尾,它还重定向到实际文件,并附加http://localhost:c/xampp/... ,这使我收到403错误禁止页面:

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. 我需要做的就是从第一个URL中获取ID并将其重写,以便将其重定向到相同的地址,然后将ID作为GET请求插入。

I'm working with XAMPP, mod_rewrite and AllowOverride All are already on 我正在使用XAMPP, mod_rewriteAllowOverride All都已启用

Thank you! 谢谢!

See if maybe this works? 看看是否可行?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM