所以,我使用带有别名的AMPPS,这样我的本地站点就可以从USB上的本地项目文件夹中运行,并从http://localhost/myproject
访问,而无需将其复制到Applications/AMPPS/www
。
然而,这导致了许多问题。最值得注意的是,包含URL重写规则的.htaccess文件不起作用。
RewriteEngine On
RewriteRule ^portfolio/([^/'.]+)/?$ /portfolio/$1.php [L]
基本上,这采用的URL类似于:
localhost/myproject/portfolio/somesite/
并搜索:
localhost/myproject/portfolio/somesite.php
除了现在,当我尝试点击任何重写的链接时,我都会遇到这样的消息:
Not Found
The requested URL /portfolio/somesite.php was not found on this server.
以前,当我不使用别名时,这个规则是有效的,但现在它完全被打破了。这是怎么回事?
添加RewriteBase
并从目标中删除前导斜杠
Options -MultiViews
RewriteEngine On
RewriteBase /myproject/
RewriteRule ^portfolio/([^/.]+)/?$ portfolio/$1.php [L,NC]