【发布时间】:2017-01-30 23:31:35
【问题描述】:
我的 WordPress 出现问题
我的 WordPress 安装在假定为 blog.lupinedream.com 的子域上。我的提供商将那里的请求转发到/public_html/blog/ 中的目录。我的登录页面位于www.lupinedream.com,它指向两个不同的子域供您选择:forums 和blog。有了这些信息,问题就来了。
什么是正确的.htaccess 配置来自动转发所有请求(包括GET、POST、PUT、...等等。针对http://www.lupinedream.com/blog 到blog.lupinedream.com?
我问的原因是因为 WordPress 在 Settings -> General 中要求 Site URL 和 WordPress URL 以允许将 WordPress 安装在子目录中,但我的行为很奇怪当我使用我当前的配置(损坏的图像、GET 和 POST 不起作用)时,当 WordPress 尝试在内部将请求指向 http://www.lupinedream.com/blog/ 时。在地址栏中,我注意到我的 URL 也变成了 foobar。
配置:
/public_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>
/public_html/blog/.htaccess:
<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 设置>常规:
Site URL : http://www.lupinedream.com/
WordPress URL : http://blog.lupinedream.com/
【问题讨论】:
标签: php wordpress .htaccess mod-rewrite