大网数据广告活动
网站运营与故障问答

How can I use the .htaccess file to redirect all web requests to a subfolder with SSL also?

· 52CE 我爱测

OK, I have a basic php website (non WordPress) that I just moved from GoDaddy to Nixihost. By default, the root website gets put in the root web folder /public_html - however instead I wanted the root website in a subfolder of th…

问题原文

原帖链接 · Sindyr · CC BY-SA 4.0

OK, I have a basic php website (non WordPress) that I just moved from GoDaddy to Nixihost. By default, the root website gets put in the root web folder /public_html - however instead I wanted the root website in a subfolder of the root web folder at /public_html/4efix.com (The website in question is my simple www.4efix.com)

At GoDaddy I had the following .htaccess file in the /public_html and it worked perfectly, it even rewrote all http requests to https ones:

# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
# Change example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?4efix.com$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/4efix.com/ 
# Don't change the following two lines. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteRule ^(.*)$ /4efix.com/$1 
# Change example.com to be your main domain again. 
# Change 'subdirectory' to be the directory you will use for your main domain 
# followed by / then the main file for your site, index.php, index.html, etc. 
RewriteCond %{HTTP_HOST} ^(www.)?4efix.com$ 
RewriteRule ^(/)?$ 4efix.com/index.php
rewriterule ^news$ "http\:\/\/eepurl\.com\/AjC-j" [R=301,L] #57e44bbcecccd

But now that I moved to Nixihost, when I visit www.4efix.com I get

Forbidden
You don't have permission to access /4efix.com/403.shtml on this server.
Server unable to read htaccess file, denying access to be safe

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

When I remove the .htaccess I get a directory listing of the /public_html folder, which seems to indicate it is a .htaccess issue.

What should my correct .htaccess file be, or do I have my .htaccess file correct and the problem is with Nixihost's server?

已采纳解答

原帖链接 · Sindyr · CC BY-SA 4.0

So for some reason I still do not fathom, the fix turned out to be altering the target directory's permission from 750 to 755. (The files within the directory did not have to have their permissions altered at all, just the folder containing the redirected site.)

That was the answer, discovered by the helpful folks at Nixihost.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。