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
Apache 如何将根文件夹重定向到子目录并在GoDaddy上使用.Htaccess隐藏它?_Apache_.htaccess_Redirect_Hide - Fatal编程技术网

Apache 如何将根文件夹重定向到子目录并在GoDaddy上使用.Htaccess隐藏它?

Apache 如何将根文件夹重定向到子目录并在GoDaddy上使用.Htaccess隐藏它?,apache,.htaccess,redirect,hide,Apache,.htaccess,Redirect,Hide,我试图将www.example.org.uk重定向到example.org.uk/subdirectory,然后隐藏子目录-因此它只在地址栏上显示www.example.org.uk 这是我使用的原始代码(来自): # BlueHost.com # .htaccess main domain to subdirectory redirect # Do not change this line. RewriteEngine on # Change example.com to be you

我试图将www.example.org.uk重定向到example.org.uk/subdirectory,然后隐藏子目录-因此它只在地址栏上显示www.example.org.uk

这是我使用的原始代码(来自):

# BlueHost.com 
# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on 
# Change example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?example.org.uk$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/subdirectory/ 
# 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 ^(.*)$ /subdirectory/$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.)?example.org.uk$ 
RewriteRule ^(/)?$ subdirectory/index.php [L]
问题是这些代码都不起作用

搜索Stackoverflow并使用advice后-这是当前代码:

Options +FollowSymLinks -Multiviews

<IfModule mod_rewrite.c>

# BlueHost.com 
# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on 
# Change example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?grampianyoga.org.uk$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/gya2/ 
# 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 ^(.*)$ /gya2/$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.)?grampianyoga.org.uk$ 
RewriteRule ^(/)?$ gya2/index.php [L]</IfModule>
Options+FollowSymLinks-多视图
#BlueHost.com
#.htaccess主域到子目录重定向
#不要改变这一行。
重新启动发动机
#将example.com更改为您的主域。
RewriteCond%{HTTP_HOST}^(www.)?grampianyoga.org.uk$
#将“subdirectory”更改为将用于主域的目录。
重写cond%{REQUEST_URI}^/gya2/
#不要更改以下两行。
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
#将“subdirectory”更改为将用于主域的目录。
重写规则^(.*)$/gya2/$1
#再次将example.com更改为您的主域。
#将“subdirectory”更改为将用于主域的目录
#然后是站点的主文件index.php、index.html等。
RewriteCond%{HTTP_HOST}^(www.)?grampianyoga.org.uk$
重写规则^(/)?$gya2/index.php[L]
不幸的是,显示了一个内部错误,错误文件说明了这一点
:[Wed Mar 26 14:22:35 2014][9566783][core:alert][client 97.74.104.6:60525]/var/chroot/home/content/83/9566783/html/.htaccess:RewriteRule:bad flag delimiters

我正在使用GoDaddy,我相信他们有自己的设置。有人有什么建议吗?试图支持,显然他们
无法帮助编写脚本。

我将更改该行

RewriteCond %{REQUEST_URI} !^/subdirectory/

因此尾随/尾随是可选的。如果您碰巧提供了一个现有的文件或目录,则带有-f-d检查的代码将不会触发。假设不是

RewriteRule ^(.*)$ /subdirectory/$1 
应该以静默方式将访问者发送到子目录(在现有URI之前插入/子目录)

我不知道为什么最后两行在那里。如果您取消跟踪/需求(如上所述),它们可能已经被处理。试着(用#)注释它们

如果仍然不起作用,GoDaddy的设置可能会有所不同。你应该与他们的技术支持人员讨论你想做什么

更新:最新.htaccess的修改版本

Options +FollowSymLinks -Multiviews

<IfModule mod_rewrite.c>

# BlueHost.com 
# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on 
# Change example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www\.)?grampianyoga\.org\.uk$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/gya2
RewriteRule ^(.*)$ /gya2/$1 [L]

</IfModule>
Options+FollowSymLinks-多视图
#BlueHost.com
#.htaccess主域到子目录重定向
#不要改变这一行。
重新启动发动机
#将example.com更改为您的主域。
RewriteCond%{HTTP_HOST}^(www\)?grampianyoga\.org\.uk$
#将“subdirectory”更改为将用于主域的目录。
重写cond%{REQUEST_URI}^/gya2
重写规则^(.*)$/gya2/$1[L]

RewriteCond%{HTTP\u HOST}^(www\)?grampianyoga\.org\.uk$
行可能是不必要的(但无害的),除非您正在处理已驻留的域、子域、附加域等。

仍然不工作,这是我在错误日志中收到的信息:[Wed Mar 26 14:22:35 2014][9566783][core:alert][client 97.74.104.6:60525/var/chroot/home/content/83/9566783/html/.htaccess:RewriteRule:bad flag delimiters您还有其他建议吗?bad flag delimiters?你的.htaccess现在看起来像什么(请将它添加到你第一篇文章的底部)。我从未在.htaccess.Ok中看到过这条消息,修改了原来的帖子。希望这有帮助。感谢您的帮助。尝试将以下内容添加到感兴趣目录上方父目录中的
.htaccess
RedirectMatch^/foo/$/foo/bar/
RedirectMatch^/foo/$/bar/baz/
。另见。
Options +FollowSymLinks -Multiviews

<IfModule mod_rewrite.c>

# BlueHost.com 
# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on 
# Change example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www\.)?grampianyoga\.org\.uk$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/gya2
RewriteRule ^(.*)$ /gya2/$1 [L]

</IfModule>