0

I recently decided to redirect my main website to my photography section, to make the photography section effectively the main website. I therefore have the following in my index.php file in the root...

<?php Header( "Location: http://notails.com/photography" );  ?>

The odd thing is, if I try to browse to http://notails.com/photography/admin which is a password protected folder, I get redirected to http://notails.com/photography. If I go to the index.php file in the root and comment out that line, then try to browse to the admin page I am able to. I don't understand why a bit of PHP in a file in one folder is redirecting me from another folder! Any ideas?

As an aside, I'd be happy for someone to tell me how to do this redirect in my htaccess file instead of in the index.php file. I looked into it but I could find instructions on lots of things except this specific thing (redirect from the 'root' to a subfolder of the site)

4

1 回答 1

0

重定向网站可能有多种解决方案。

最简单的方法是修改根目录中的 .htaccess 文件(即 public_html 或类似的东西;无论您当前的 index.php 或 .html 文件在哪里)。

(注意:使用 index.php 时,必须重命名或删除 index.html)。

(将以下内容添加到 .htaccess 文件的底部...我说的是添加而不是修改,以防万一您不熟悉内容并且不确定要更改什么)。

解决方案:(.htaccess 的最后一行)

RedirectMatch 永久 ^/$ http://yourdomain/yoursubdirectory/index.php

关于访问:我不清楚您是如何“浏览到管理员”的。它是在您网站的页面中完成的(通过您网站目录结构的某些显示)吗?

通常,请确保“/yourdomain/yoursubdirectory/index.php”没有设置并为根目录使用特定变量,然后将“photography/admin”附加到它。如果是这种情况……您现在将得到不存在的“/yourdomain/yoursubdirectory/yoursubdirectory/admin”。

您可能只需要在“/photography/index.php”文件中更正该引用。

希望这里有帮助。

J. http://omki.us

于 2012-04-23T17:34:59.390 回答