我正在尝试允许启用MultiViews的Clean-Urls.
我拥有的所有页面都在根文件夹中.
我想要实现以下目标:
(current-status -> what I am trying to achieve)
1. foo.com/services.php -> foo.com/services
2. foo.com/services == foo.com/services/
3. foo.com/services.php/second-level/ == foo.com/services/second-level
Run Code Online (Sandbox Code Playgroud)
该services
是不是 一个文件夹,我爆炸$_SERVER['PATH_INFO']
并获得第二级的路径数据.
我已经实现了第一个,但是当我启用MultiViews
,使用.htaccess
文件并写入重写时它失败了.
Options +Indexes +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
Run Code Online (Sandbox Code Playgroud)
(这显然会失败,因为它会将请求更改为services/second-level.php).我知道我可以写入多个重写.htaccess
,并有条件地重定向.
但奇怪的是,在实时环境(共享主机)上,它正在工作,根文件夹中没有任何.htaccess
文件.由于它是共享主机,我无法读取配置文件.
有关我应该更改(in apache.conf
或*.conf
)以实现上述内容的配置的任何想法?
如果重要,我正在使用Apache/2.2.22
,这个问题在更新后开始发生.