【发布时间】:2015-06-05 22:33:56
【问题描述】:
我的 Htaccess 文件有点问题。
RewriteEngine On
RewriteBase /testwebsite/
RewriteRule ^home/?$ index.php
我想要完成的是:每当客户端访问 localhost/testwebsite/index.php 时,他必须被重定向到干净的 url (localhost/testwebsite/home)。每当访问者访问 localhost/testwebsite/home 时,他必须呆在那里,但仍然会显示 index.php 的内容。
目前每次访问 localhost/testwebsite/home 都会显示 index.php 的内容,但是每次访问 localhost/testwebsite/index.php 时,客户端仍然会看到“丑陋”的 url。
我在互联网上查找了所有信息,但 mod_rewriting 的工作原理并没有深入到我的脑海中。希望能得到帮助,谢谢!
【问题讨论】:
-
我不确定它是如何实现的,但 Mod_rewrite 确实是掌握乒乓球的痛苦。我发现很多很多的试验和错误都有帮助。并学习 REGEX。
标签: php apache .htaccess mod-rewrite