阿帕奇清理URL以多视图启用 [英] Apache Clean-Urls with MultiViews enabled

查看:215
本文介绍了阿帕奇清理URL以多视图启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让干净的网址,具有多视图功能。

I'm trying to allow Clean-Urls, having MultiViews enabled.

所有我的网页,在根文件夹本身。

All the pages I have, are in the root folder itself.

我想实现以下目标:

(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

服务不可以文件夹,我爆炸 $ _ SERVER ['PATH_INFO'] 并获得二级路径数据。

The services is not a folder, I explode $_SERVER['PATH_INFO'] and get the second-level path data.

我已经实现了第一个,但它失败时启用多视​​图,使用的.htaccess 文件续写改写。

I have already achieved the first one, but it fails when I enable MultiViews, using a .htaccess file and writing a rewrite.

Options +Indexes +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]

(这显然会失败,因为这将要求改变到服务/第二level.php)。 我知道我可以写多个重写的.htaccess ,并有条件地重定向。

(Which would obviously fail, since it would change the request to services/second-level.php). I know I can write multiple rewrites in the .htaccess, and conditionally redirect.

但奇怪的事实是,在真实环境(共享托管),它是工作,没有任何的.htaccess 在根文件夹。由于它是一个共享的主机,我无法读取配置文件。

But the strange fact is that on the live environment (shared hosting), it is working, without any .htaccess file in the root folder. Since it is a shared hosting, I cannot read the configuration file.

这是我应该改变哪些配置任何想法(在的apache.conf *。CONF )来实现的以上?

Any ideas on what configuration should I change (in apache.conf or *.conf) to achieve the above?

如果它的事项,我使用的Apache / 2.2.22 ,而这个问题开始更新后发生。

If it matters, I'm using Apache/2.2.22, and this problem started happening after the update.

推荐答案

我终于想通了,如何解决这个问题。

I finally figured out how to solve it.

这工作,消除了的.htaccess 文件共有,并改变虚拟目录保留以下设置:

This works, removing the .htaccess file altogether, and changing the Virtual Directory to keep the following settings :

<VirtualHost *:80>
    ServerAdmin my-email-id
    ServerName foo.bar
    DocumentRoot /var/www/sites/foo/

    <Directory /var/www/sites/foo/>
        Options +FollowSymLinks +MultiViews +Indexes
        DirectoryIndex index.php
        AddType application/x-httpd-php .php
    </Directory>

</VirtualHost>

这可以帮助我得到的所有网页的工作,正是因为他们工作在服务器上,没有任何改写条件。

This helps me get all the pages to work, exactly as they were working on the server, without any of the Rewrite Conditions.

这篇关于阿帕奇清理URL以多视图启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆