如何解决在centos 7上使用虚拟主机配置.htaccess错误“ 404未找到”
主机文件
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
localhost app.olpes.co
localhost apisubject.olpes.co
httpd.conf
ServerName localhost
.
.
.
<VirtualHost *:80>
ServerAdmin desarrollo@olpes.co
ServerName app.olpes.co
ServerAlias olpes.co
DocumentRoot /var/www/html/appother
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerAdmin desarrollo@olpes.co
ServerName apisubject.olpes.co
ServerAlias olpes.co
DocumentRoot /var/www/html/apisubject
<Directory /var/www/html/apisubject>
Options -Indexes +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
路径
/var/www/html/
- appother
- apisubject
- .htaccess
- index.php
.htaccess文件
<IfModule mod_rewrite.c>
RewriteBase /apisubject/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
</IfModule>
索引文件
<?php
phpinfo();
?>
结果
-
请求http://apisubject.olpes.co/ => OK结果
-
请求http://apisubject.olpes.co/abc/x =>未找到结果
无法在.htaccess中使用我的配置
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。