Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 重定向工作,但无法加载.css_.htaccess - Fatal编程技术网

.htaccess 重定向工作,但无法加载.css

.htaccess 重定向工作,但无法加载.css,.htaccess,.htaccess,你好。 我有一个受.htaccess保护的站点,它将所有内容重定向到/pb目录,但可直接访问的/cron目录除外(稍后它将受到保护)。 我的htaccess可以工作(它可以根据我的需要重定向),但是我无法将我直接调用的.css.js文件加载到我的索引页中。 我是否必须在我的/pb目录中添加一个新的.htaccess以允许访问.css,或者我可以在我的根htaccess中这样做?我不明白 My.htaccess文件(https行不能被删除“hostinger”) 感谢您的帮助首先,我已经修复了您的

你好。 我有一个受.htaccess保护的站点,它将所有内容重定向到/pb目录,但可直接访问的/cron目录除外(稍后它将受到保护)。 我的htaccess可以工作(它可以根据我的需要重定向),但是我无法将我直接调用的.css.js文件加载到我的索引页中。 我是否必须在我的/pb目录中添加一个新的.htaccess以允许访问.css,或者我可以在我的根htaccess中这样做?我不明白

My.htaccess文件(https行不能被删除“hostinger”)


感谢您的帮助

首先,我已经修复了您的htacces规则文件,并在规则文件中发表了评论。将您的htaccess规则文件按如下样式保存,确保将其放置在pb文件夹所在的同一文件夹中。另外,请在测试URL之前清除浏览器缓存

Options -Indexes -MultiViews
RewriteEngine on
##Apply https rules here.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?XXXXXXXXX.net [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

##Handling base URI of site.
RewriteRule ^/?$ pb/ [R=301,L]

##Blocking pb uri pages non existing ones.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^pb/ - [NC,L]
##making all uris which are files to pb folder.
RewriteCond %{DOCUMENT_ROOT}/pb/$1 -f
RewriteRule ^(.+)/?$ pb/$1 [L]
##Making non existing uris to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ pb/index.php?path=$1 [L,QSA]

order deny,allow
deny from all
allow from XX.XXX.XXX.XX
JS/CS重写/重定向:
您可能需要使用base标记来修复js和其他相关资源。如果您使用相对路径链接js文件,那么该文件显然会得到404,因为它正在查找URL路径。例如,如果URL路径是/file/而不是file.html,那么您的相对资源是从/file/加载的,该文件不是目录,而是重写的html文件。要解决此问题,请将链接设置为绝对链接或使用基本标记。在您的网页标题中添加此
,以便您的相关链接可以从正确的位置加载。

谢谢您,但现在的问题是,当我转到www.XXXXXX.net时,它没有重定向到www.XXXXXX.net/pb/index.php,我可以看到所有目录框架(/pb/cron)@rooky06,好的,我现在已经更改了规则,你能检查一下编辑好的规则并告诉我它是怎么回事吗?谢谢。XXXXX.net->错误403,XXXX.net/pb:好的,XXXXX.net/cron->错误403。另一个原因是我不能更改4行第一行,因为hostinger写了它,谢谢你,但有一个问题。xxxx.net正确重定向到xxxxxx.net/pb,并且未看到/pb:完美!不存在的xxxxxx.net/files或dir将正确重定向到xxxxxx.net/pb,并且未看到/pb:完美!),xxxxx.net/pb重新选择正确,但xxxxxxx.net/cron-->错误403
Options -Indexes -MultiViews
RewriteEngine on
##Apply https rules here.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?XXXXXXXXX.net [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

##Handling base URI of site.
RewriteRule ^/?$ pb/ [R=301,L]

##Blocking pb uri pages non existing ones.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^pb/ - [NC,L]
##making all uris which are files to pb folder.
RewriteCond %{DOCUMENT_ROOT}/pb/$1 -f
RewriteRule ^(.+)/?$ pb/$1 [L]
##Making non existing uris to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ pb/index.php?path=$1 [L,QSA]

order deny,allow
deny from all
allow from XX.XXX.XXX.XX