我有三个站点在一个共享主机(Bluehost)中运行一个专用的IP地址。 说明如下:
example.com =>这是主站点和域名,是一个WP example.net =>这是一个附加域名(不知道你是否熟悉这个术语),并正在运行另一个WP站点 subsite.example.net =>这是一个独立的PHP应用程序 每个WP都有它自己的.htacess文件,如下所示:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
有了这个.htaccess文件,两个WP网站都可以正常工作,但独立的应用程序却没有。 如果我删除.htaccess文件然后是相反的,独立的应用程序工作,但WP网站没有。
有没有可以帮助我find解决这个问题?
更新
我正在使用独立PHP应用程序的.htaccess文件的以下configuration:
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] # Add Caching. <FilesMatch ".(ico|jpg|jpeg|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=10800" </FilesMatch> # Prevent viewing of htaccess file. <Files .htaccess> order allow,deny deny from all </Files> # Prevent directory listings Options All -Indexes # Compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript </IfModule>
但是因为我一点击任何链接就被踢出了应用程序就不起作用了。
独立网站位于/public_html/plataforma而WP位于/public_html 。 为什么我现在做错了?
重要的是底层的文件/目录结构。 如果这三个站点基本上在同一个帐户上 – 同一个父目录 – 那么每个站点可能都在一个单独的子目录中(这通常是在共享环境中缺省的addon和subdomains),每个站点应该有一个单独的.htaccess文件子目录。 不是一个人。
更新#1:尝试添加一个例外的WordPress .htaccess专门排除任何重写,如果通过子域访问。 例如:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{HTTP_HOST} !^subsite\.example\.net$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
然而,这真的不应该是必要的,因为(如注释中所述),独立应用程序的.htaccess文件中的mod_rewrite指令应完全覆盖这些(因为独立应用程序位于子目录中)。
另一个向WordPress模块添加代码的警告是,这可能会被下一次更新覆盖。
更新#2:或者,尝试将RewriteOptions指令添加到独立应用程序的.htaccess文件(位于子目录中):
<IfModule mod_rewrite.c> RewriteEngine on RewriteOptions IgnoreInherit :
如果这样工作,那么似乎表明在服务器configuration中有一个RewriteOptions InheritDown[Before]指令,允许父目录中的mod_rewrite指令被inheritance。 请注意, IgnoreInherit和InheritDown[Before]是Apache 2.4+的特性。
(编辑:看来OP是在Apache 2.2.31上,所以上面的指令导致500内部服务器错误。)
更新#3:您也可以尝试从两个.htaccess文件中删除RewriteBase /指令,并删除WordPress RewriteRule replace中的斜杠前缀以匹配独立应用程序的.htaccess文件中的规则。 所以,WordPress的.htaccess文件变成:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] </IfModule> # END WordPress
以前的最后一行是: RewriteRule . /index.php [L] RewriteRule . /index.php [L] (即用斜杠前缀)。 斜杠表示一个根目录的URLpath,没有斜杠现在相对于包含.htaccess文件的目录。
为您的独立PHP应用程序创build.htaccess文件,将您的代码redirect到subsite.example.net