Php .htaccess和WordPress
我的WordPress有问题 我的WordPress安装在一个子域上,该子域假定为Php .htaccess和WordPress,php,wordpress,.htaccess,mod-rewrite,Php,Wordpress,.htaccess,Mod Rewrite,我的WordPress有问题 我的WordPress安装在一个子域上,该子域假定为blog.lupinedream.com。我的提供商将在那里提出的请求转发到/public\u html/blog/中的目录。我的登录页面位于www.lupinedream.com,指向两个不同的子域供您选择:论坛,和博客。有了这些信息,问题来了 自动转发所有请求(包括,GET,POST,PUT,…等)的正确.htaccess配置是什么http://www.lupinedream.com/blog到blog.lup
blog.lupinedream.com
。我的提供商将在那里提出的请求转发到/public\u html/blog/
中的目录。我的登录页面位于www.lupinedream.com
,指向两个不同的子域供您选择:论坛
,和博客
。有了这些信息,问题来了
自动转发所有请求(包括,GET
,POST
,PUT
,…等)的正确.htaccess
配置是什么http://www.lupinedream.com/blog到blog.lupinedream.com
我之所以这么问是因为WordPress要求站点URL
和WordPress URL
在Settings->General中允许WordPress安装在子目录中,但当我使用我当前的配置时,我一直有奇怪的行为(图像损坏,GET和POST不工作)当WordPress试图在内部将请求指向http://www.lupinedream.com/blog/
。在地址栏中,我注意到我的URL也在地址栏中
配置:
/public\u html/.htaccess
:
Options ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch -Indexes
## File Type Specifications
AddType text/html .html .htm .xml
AddType text/plain .txt .text .doc .md .nfo .info
<IfModule mod_cgi.c>
AddHandler cgi-script .cgi .pl .py .jsp .asp .shtml .sh
AddType cgi-script .cgi .pl .py .jsp .asp .shtml .sh
</IfModule>
<iFModule mod_php.c>
AddHandler application/x-httpd-php70 .php .php3 .php4 .php5 .php53 .phtml .tpl .html
AddType application/x-httpd-php70 .php .php3 .php4 .php5 .php53 .phtml .tpl .html
</IfModule>
DirectoryIndex index.html index.php under_construction.html
## Query limits
<Limit GET POST>
Order deny,allow
Deny from All
Allow from All
</Limit>
<Limit PUT DELETE>
Order deny,allow
Deny from All
Allow from localhost
</Limit>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
WordPress设置>常规:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
网站URL
:
WordPress URL
:假设blog.example.com
和www.example.com/blog
下面的结构相同,重定向如下所示
RewriteRule ^blog/(.*)$ http://blog.example.com/$1 [R,L]
由于您的提供商已经将
blog.example.com
重写为/blog/…
,您应该能够删除/public\u html/.htaccess中现有的重写规则
我在这里使用了子域示例:,但重定向似乎不起作用。如果我转到blog.example.com
我可以查看页面源代码.blog.example.com的所有内容都有两个“/”从http://www.example.com/blog
。这似乎也会以某种方式影响外部链接,比如谷歌。是的,但是你的Wordpress网站位于/blog
下方,不是吗?而且你在/blog/.htaccess
中也有这个片段。你把重写规则放到/public\u html/.htaccess中了吗代码>?不,我把它放在了/public\u html/blog/.htaccess
。我的错。但我发现我的CNAME记录在我的注册者门户中无法正常工作,所以我也在做注册者转移,以确保它100%工作。我需要从DynDNS转移它。