简体   繁体   English

.htaccess和WordPress

[英].htaccess and WordPress

I'm having problems with my WordPress My WordPress is installed on a subdomain which assumes blog.lupinedream.com . 我的WordPress出现问题我的WordPress安装在假定为blog.lupinedream.com的子域中。 My provider forwards requests made there to a directory in /public_html/blog/ . 我的提供程序将在那里发出的请求转发到/public_html/blog/的目录。 My landing page is located at www.lupinedream.com , that points at two different subdomains for you to choose from: forums , and blog . 我的目标网页位于www.lupinedream.com ,它指向两个不同的子域供您选择: forumsblog With that information, here's the question. 有了这些信息,这就是问题所在。

What is the proper .htaccess configuration to auto-forward all requests (including as well, GET , POST , PUT , ... etc. directed at http://www.lupinedream.com/blog to blog.lupinedream.com ? 什么是正确.htaccess配置为自动转发所有请求(包括为好, GETPOSTPUT ,...等等冲着http://www.lupinedream.com/blogblog.lupinedream.com

Reason I'm asking is because WordPress asks for Site URL and WordPress URL in Settings -> General to allow WordPress to be installed in a subdirectory, but I've been getting weird behavior when I use my current config (broken images, GET and POST not working) when WordPress attempts to internally point requests at http://www.lupinedream.com/blog/ . 我问的原因是因为WordPress在设置->常规中要求提供Site URLWordPress URL ,以允许将WordPress安装在子目录中,但是当我使用当前配置时出现奇怪的行为(损坏的图像,GET和当WordPress尝试在内部将请求指向http://www.lupinedream.com/blog/时,POST无法正常工作。 In the address bar, I'm noticing my URL going foobar as well. 在地址栏中,我也注意到我的URL也变成了foobar。


Config: 配置:

/public_html/.htaccess : /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 : /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 Settings > General : WordPress 设置>常规

Site URL : http://www.lupinedream.com/ Site URLhttp : //www.lupinedream.com/

WordPress URL : http://blog.lupinedream.com/ WordPress URLhttp//blog.lupinedream.com/

Assuming the structure below blog.example.com and www.example.com/blog is the same, a redirect would look like 假设blog.example.comwww.example.com/blog下面的结构相同,则重定向看起来像

RewriteRule ^blog/(.*)$ http://blog.example.com/$1 [R,L]

Since your provider already rewrites blog.example.com to /blog/... , you should be able to remove the existing RewriteRules in /public_html/.htaccess . 由于您的提供者已经将blog.example.com重写为/blog/... ,因此您应该能够删除/public_html/.htaccess现有的RewriteRules

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM