在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 [email protected]
    ServerName app.olpes.co
    ServerAlias olpes.co
    DocumentRoot /var/www/html/appother
    DirectoryIndex index.PHP
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    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();
?>

结果

  1. 请求http://apisubject.olpes.co/ => OK结果

    OK Result

  2. 请求http://apisubject.olpes.co/abc/x =>未找到结果

NOT FOUND

无法在.htaccess中使用我的配置

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)