dsfsad089111 2013-01-06 13:47
浏览 77
已采纳

启用了MultiViews的Apache Clean-Urls

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

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

I am trying to achieve the following :

(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

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

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]

(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.

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.

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

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

  • 写回答

3条回答 默认 最新

  • du16178 2013-01-13 18:38
    关注

    I finally figured out how to solve it.

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)