【发布时间】:2011-06-11 21:28:13
【问题描述】:
我创建了一个指向我的 index.php 的符号链接(使用 ln -s index.php 测试),以尝试获得一个没有 .php 扩展名的“更漂亮”的 url。 但是,当我访问 https://myservername.com/test 时,我得到的是原始 php 文件而不是解释的内容。
如果可能的话,我想避免打开 mod_rewrite,因为它只用于这个文件(我使用的是 CodeIgniter 框架,它为其余文件进行 url 转换)。
有没有办法让 apache 读取真正的目标文件而不是符号链接来确定它是一个 php 脚本?有没有更好的方法来实现这一点?
【问题讨论】:
-
是的,完成它的更好方法是使用适当的工具(在本例中为
mod_rewrite)... -
好的,将以下内容添加到 httpd.conf 中的
部分就可以了(我将 index.php 重命名为 ci.php):
RewriteEngine on
RewriteRule ^test $ /test/ [R]
RewriteRule ^test/(.*)$ ci.php/$1 [L] -
好吧,用实际的回车替换上面的
标签。 -
@ircmaxell:合适的工具是 Alias...瑞士刀可以做很多事情,但有时 KISS 规则适用。
标签: php linux apache symlink friendly-url