当前位置:Gxlcms > PHP教程 > xampp中apache的根目录301问题

xampp中apache的根目录301问题

时间:2021-07-01 10:21:17 帮助过:23人阅读

Apache的新手,安装XAMPP之后,apache的端口改为7088,想装个wordpress,修改了apache的httpd.conf的根目录配置如下:

DocumentRoot "C:/xampp/wordpress"

    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
    Order allow,deny
    Allow from all

访问http://localhost:7088/和http://localhost:7088/index.php,apache的日志返回301。

::1 - - [24/Jan/2016:20:53:33 +0800] "GET / HTTP/1.1" 301 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
::1 - - [24/Jan/2016:20:54:08 +0800] "GET /index.php HTTP/1.1" 301 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

但是访问http://localhost:7088/index.html和http://localhost:7088/wp-login.php都能返回200。

::1 - - [24/Jan/2016:20:41:07 +0800] "GET /wp-login.php HTTP/1.1" 200 2713 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
::1 - - [24/Jan/2016:20:59:32 +0800] "GET /index.html HTTP/1.1" 200 5 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

我发现wordpress的siteURL只要修改为和访问地址一致的时候就会出现这个问题,如果用域名访问wordpress根目录,而siteurl是 http://localhost:7088 的时候,可以访问成功,只是wordpress的主页链接还是指向localhost。

回复内容:

Apache的新手,安装XAMPP之后,apache的端口改为7088,想装个wordpress,修改了apache的httpd.conf的根目录配置如下:

DocumentRoot "C:/xampp/wordpress"

    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
    Order allow,deny
    Allow from all

访问http://localhost:7088/和http://localhost:7088/index.php,apache的日志返回301。

::1 - - [24/Jan/2016:20:53:33 +0800] "GET / HTTP/1.1" 301 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
::1 - - [24/Jan/2016:20:54:08 +0800] "GET /index.php HTTP/1.1" 301 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

但是访问http://localhost:7088/index.html和http://localhost:7088/wp-login.php都能返回200。

::1 - - [24/Jan/2016:20:41:07 +0800] "GET /wp-login.php HTTP/1.1" 200 2713 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
::1 - - [24/Jan/2016:20:59:32 +0800] "GET /index.html HTTP/1.1" 200 5 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"

我发现wordpress的siteURL只要修改为和访问地址一致的时候就会出现这个问题,如果用域名访问wordpress根目录,而siteurl是 http://localhost:7088 的时候,可以访问成功,只是wordpress的主页链接还是指向localhost。

找到解决的方法了,找到wp-content/themes/[主题名]/functions.php

在第一行增加一行

remove_filter('template_redirect', 'redirect_canonical');

你看一下你的httpd.conf的配置文件里DirectoryIndex设置的是怎样的?

人气教程排行