Wordpress 重写.htaccess中的规则Apache指令无效

Wordpress 重写.htaccess中的规则Apache指令无效,wordpress,apache,.htaccess,https,openshift,Wordpress,Apache,.htaccess,Https,Openshift,我的PHP wordpress应用程序的.htaccess文件位于clone目录/PHP/中,我可以说它已被OpenShift服务器识别。但有些重写规则和重写条件似乎不起作用。由于爬虫程序可以通过http和https访问该应用程序,因此我尝试为ssl和http连接创建单独的robots.txt 我已经用几种不同的代码研究了好几个小时,但没有一种有效。其中一些是如下 1. 重新启动发动机 RewriteCond%{HTTP:X-Forwarded-Proto}=https 重写规则^robots

我的PHP wordpress应用程序的.htaccess文件位于
clone目录/PHP/
中,我可以说它已被OpenShift服务器识别。但有些重写规则和重写条件似乎不起作用。由于爬虫程序可以通过http和https访问该应用程序,因此我尝试为ssl和http连接创建单独的robots.txt

我已经用几种不同的代码研究了好几个小时,但没有一种有效。其中一些是如下

1.

重新启动发动机
RewriteCond%{HTTP:X-Forwarded-Proto}=https
重写规则^robots.txt$robots-https.txt[L]
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
2.

重新启动发动机
选项+FollowSymlinks
重写cond%{SERVER_PORT}^443$
重写规则^robots.txt$robots-https.txt[L]
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
3.

重新启动发动机
RewriteCond%{HTTP:X-Forwarded-Proto}=https
重写规则^robots.txt$robots-https.txt[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
4.

重新启动发动机
在$[NC]上重写cond%{HTTPS}^
重写规则^robots.txt$robots-https.txt[L]
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
5.

重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
RewriteCond%{HTTP:X-Forwarded-Proto}=https
重写规则^robots.txt$robots-https.txt[L]
当我访问时,url不会重定向。URL总是一样的。

保持如下状态:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} https [OR]
RewriteCond %{SERVER_PORT} =443
RewriteRule ^robots\.txt$ /robots-https.txt [L,R,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

确保robots.txt和第二个robots.txt存在于repo的php目录中。unlessopenshift将把它指向一个默认的robots.txt,尽管我不确定该文件存储在哪里。我希望url会改变,但根据http协议,只有robots.txt的内容会改变

我简直不敢相信我花了将近一半的时间在这上面

如果其他人对谷歌的重复内容问题有疑问,下面是我的.htaccess现在的样子

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP:X-Forwarded-Proto} https
RewriteRule ^robots.txt$ robots-ssl.txt [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

重新启动发动机
重写基/
重写cond%{HTTP:X-Forwarded-Proto}https
重写规则^robots.txt$robots-ssl.txt[L]
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteRule ^robots.txt$ robots-https.txt [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} ^on$ [NC]
RewriteRule ^robots.txt$ robots-https.txt [L]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteRule ^robots.txt$ robots-https.txt [L]
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} https [OR]
RewriteCond %{SERVER_PORT} =443
RewriteRule ^robots\.txt$ /robots-https.txt [L,R,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP:X-Forwarded-Proto} https
RewriteRule ^robots.txt$ robots-ssl.txt [L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>