PHP URL 重写 - .htaccess 和 MAMP
PHP URL ReWrites - .htaccess & MAMP
我已经玩这个很久了,但似乎无法让它工作 - 我不知道这是 .htaccess 的问题,还是我正在使用 MAMP @ localhost:8888.
我正在尝试从中清理我的 URLS;
localhost:8888/profile.php?user=testuser
到
localhost:8888/testuser (localhost:8888 will be replaced by my TLD once live).
我在 .htaccess
中尝试使用的代码是;
RewriteEngine On
ReWriteRule ^([a-z]+)$ profile.php?user=
(我也尝试在 ^ 之前添加 http:/localhost:8888/
)
我得到一个 404
任何人都可以帮忙,因为这让我抓狂!
您似乎漏掉了 /。默认情况下,您的 ModRewrite 无法识别它。所以您的浏览器正在尝试在您的根目录中找到文件夹 "testuser"。
请看这里:
https://www.sitepoint.com/forums/showthread.php?288690-Mod-Rewrite-simulating-a-folder-structure
编辑:
试试这个:
RewriteRule ^([^/]+)/$ /profile.php?user=
我已经玩这个很久了,但似乎无法让它工作 - 我不知道这是 .htaccess 的问题,还是我正在使用 MAMP @ localhost:8888.
我正在尝试从中清理我的 URLS;
localhost:8888/profile.php?user=testuser
到
localhost:8888/testuser (localhost:8888 will be replaced by my TLD once live).
我在 .htaccess
中尝试使用的代码是;
RewriteEngine On
ReWriteRule ^([a-z]+)$ profile.php?user=
(我也尝试在 ^ 之前添加 http:/localhost:8888/
)
我得到一个 404
任何人都可以帮忙,因为这让我抓狂!
您似乎漏掉了 /。默认情况下,您的 ModRewrite 无法识别它。所以您的浏览器正在尝试在您的根目录中找到文件夹 "testuser"。
请看这里:
https://www.sitepoint.com/forums/showthread.php?288690-Mod-Rewrite-simulating-a-folder-structure
编辑:
试试这个:
RewriteRule ^([^/]+)/$ /profile.php?user=