简体   繁体   English

如何在 Apache 中启用多视图

[英]How to enable MultiViews in Apache

I was trying to achieve that, If someone opens the URL /login then It should open the /login/index.php file.我试图实现这一点,如果有人打开 URL /login 那么它应该打开 /login/index.php 文件。 and it requires that multiviews needs to be enabled, I found the below options它需要启用多视图,我找到了以下选项

1. Adding in the.htacces 1. Adding in the.htacces

<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>
  1. Add the multiview option to your apache conf file, like below将多视图选项添加到 apache conf 文件中,如下所示

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

but these solutions didn't work.但这些解决方案没有奏效。

Finally, I found the below solution that worked for me, hope It will help someone else too.最后,我找到了以下对我有用的解决方案,希望它对其他人也有帮助。

Here is the solution:这是解决方案:

open the below file打开下面的文件

sudo nano /etc/apache2/mods-enabled/mime.conf

Find the below line in the file在文件中找到以下行

AddType application/x-httpd-php .php .phtml .html .htm

Uncomment(If commented) and add.php If It does not contain it.取消注释(如果已注释)并添加.php 如果它不包含它。 Restart the server重启服务器

sudo service apache2 restart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM