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条)

报告相同问题?

悬赏问题

  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集