Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WordPress与www的访问问题_Wordpress_.htaccess - Fatal编程技术网

WordPress与www的访问问题

WordPress与www的访问问题,wordpress,.htaccess,Wordpress,.htaccess,我有一个WordPress网站,默认设置为直接访问www。一切都很完美,但是我有一些自定义编码的部分,可以转到本地服务的“配置文件”页面,住宿等。这在开发过程中效果很好,但是当您通过www.example.com/services/example-here/访问链接时,它会重定向到example.com/wp-content/themes/theme-here/custom/services.php?slug=example-here 我的网站主人告诉我,是WordPRess引起了这个问题,但是

我有一个WordPress网站,默认设置为直接访问www。一切都很完美,但是我有一些自定义编码的部分,可以转到本地服务的“配置文件”页面,住宿等。这在开发过程中效果很好,但是当您通过www.example.com/services/example-here/访问链接时,它会重定向到example.com/wp-content/themes/theme-here/custom/services.php?slug=example-here

我的网站主人告诉我,是WordPRess引起了这个问题,但是所有的东西都说www.example.com/(siteurl等)

以下是htaccess文件中的代码:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteRule ^.*services/(.*)/$ /wp-content/themes/theme-here/custom/services.php?slug=$1 [QSA,L]
RewriteRule ^.*accommodation/(.*)/$ /wp-content/themes/theme-here/custom/accommodation.php?slug=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写规则^.*services/(.*)/$/wp content/themes/theme here/custom/services.php?slug=$1[QSA,L]
重写规则^.*住宿/(.*)/$/wp content/themes/theme here/custom/accountability.php?slug=$1[QSA,L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
如果我检查了所有设置,那么mod re write是否会成为apache conf中的主机问题?我还可以补充一点,代码在不添加www的情况下可以完美工作,但我的客户需要www

  • 在该行上方添加一个
    www
    强制规则。htaccess就在
    RewriteBase/
    行下方:

    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
    
  • 确保在WP的
    permalink
    设置中,您有
    www


  • 没什么区别。同样的事情正在发生。什么会导致它忽略htaccess mod_重写规则(仅部分)打开firebug并加载同一页面。查看网络选项卡中的内容。
    get/services/garden city cabs/302找到toowoombaconferences.com.au 389 B 103.9.170.219:80 77ms get services.php?slug=garden city cabs 301永久移动到toowoombaconferences.com.au 413 B 103.9.170.219:80
    ,因此最后的301是强制一个URL中没有
    www
    的域。您是否尝试过不同的浏览器来避免301缓存问题。嗨,我自己设法解决了它,不知道它是什么。。我只是把虚拟目录改成了一个不同的名字,然后又改回来了,它成功了。。。可能是WordPress的问题。