大网数据广告活动
服务器运维问答

Apache redirect to index.php

· 52CE 我爱测

I've got the below virtual host configuration on Centos 6.5 running apache 2.4. <VirtualHost *:4323> ServerName www.first.com ServerAlias first.com DocumentRoot /var/www/first.com DirectoryIndex index.html RewriteEngine on Rewrit…

问题原文

原帖链接 · usert4jju7 · CC BY-SA 3.0

I've got the below virtual host configuration on Centos 6.5 running apache 2.4.

<VirtualHost *:4323>
        ServerName www.first.com
        ServerAlias first.com
        DocumentRoot /var/www/first.com
        DirectoryIndex index.html
        RewriteEngine on
        RewriteRule ^index\.html$ index.php$1 [L,R=301]
        ErrorLog /var/www/first.com/log/error.log
        CustomLog /var/www/first.com/log/requests.log combined
</VirtualHost>

When I go to server_IP:4323 the default HTTP page comes up. How could I get the redirection to index.php working please?

The httpd.conf configuration is here

The apache details below -

Server version: Apache/2.2.15 (Unix)
Server built:   Mar 22 2016 19:03:53
Server's Module Magic Number: 20051115:25
Server loaded:  APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

已采纳解答

原帖链接 · Jacob Reiter · CC BY-SA 4.0

In the apache2.conf or httpd.conf, change*

DirectoryIndex index.html

To

DirectoryIndex index.php

Or multiple :

DirectoryIndex index.php index.html

<VirtualHost *:4323>
        ServerName www.first.com
        ServerAlias first.com
        DocumentRoot /var/www/first.com
        DirectoryIndex index.php
        RewriteEngine on
        RewriteRule ^index\.html$ index.php$1 [L,R=301]
        ErrorLog /var/www/first.com/log/error.log
        CustomLog /var/www/first.com/log/requests.log combined
</VirtualHost>

Then restart apache.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-04-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。