【发布时间】:2019-05-21 20:18:41
【问题描述】:
我搜索了这个,但没有一个解决方案适合我。 我已经从这里尝试了许多不同的“解决方案”,但都没有奏效。
我在我的域的主根目录中安装了 WordPress,例如 example.com/index.php
所以我在 example.com 的根目录中有一个 WordPress 的 .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# 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>
之后,我将其他 PHP 脚本安装在主域的子目录中,例如 example.com/app/index.php
example.com/app/index.php 子目录中 PHP 脚本的 .htaccess :
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
RewriteEngine On
RewriteBase /
# RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
# RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^search/(.+)$ /search.php?q=$1
RewriteRule ^search/([^/]*?)/page/([^/]*?)/$ /search.php?q=$1&token=$2
RewriteRule ^search/([^/]*?)/$ /search.php?q=$1
RewriteRule ^download/([^/]*?)/page/([^/]*?)/$ /search.php?q=$1&token=$2
RewriteRule ^download/([^/]*?)/$ /search.php?q=$1
RewriteRule ^watch/(.+)$ /watch.php?id=$1 [L]
RewriteRule ^home/(.+)$ /index.php?q=&page=$1 [L]
RewriteRule ^(cache/|submit\.php|head\.php|head_mobile\.php|foot\.php|foot_mobile\.php|includes\.php|config\.php) - [F,L,NC]
RewriteRule ^sitemap.xml$ /sitemap.php [L]
RewriteRule ^dmca$ /dmca.php
RewriteRule ^privacy$ /privacy.php
RewriteRule ^contact$ /contact.php
现在我的 PHP 脚本无法正常工作,并且在安装 PHP 脚本的子目录中无法访问所有文件,包括 CSS、JS、图像。
我希望 URL 应该是这样的:
https://example.com/app/watch/wVS-hHZsAIg
https://example.com/app/contact-us
https://example.com/app/dmca
https://example.com/app/css/style.css
但是上述所有 URL 都不起作用,并且它重定向到 WordPress 安装页面并给出如下 404 错误:
https://example.com/watch/wVS-hHZsAIg
https://example.com/contact-us
https://example.com/dmca
https://example.com/css/style.css
我的 CSS、JS 和其他相关资源无法正常工作。这个问题。
而且 .htaccess 会阻止 CSS、javascript 和图像通过 example.com/app/index.php 访问
【问题讨论】: