1

我根据每个函数一个子目录的想法设计了一个 php/mysql/query,所以我的目录结构如下所示:

公共_html\

 ..users\ (all user related files are in this folder)
 ..events\ (all event related files are in this folder)
 ..groups\ (all group related files are in this folder)
 ..layouts\ (global header, global footer, and global navigation include files are in here)

用户、事件或组文件夹中的任何页面都包含页眉、页脚和导航文件,因此它们都保留了一个主题。因此,导航文件的所有链接都设置为 ../functionfolder/file.php",因为您通常位于其中一个函数文件夹中,所以它可以正常工作。

但是我忘记了 public_html 中的索引文件,当我从该目录(不是子文件夹)中包含我的页眉、页脚和导航时,“../”的一切都搞砸了。

我已经创建了一个单独的导航文件,它将使高级目录中的文件工作,但我意识到我所有的图片和脚本包含都搞砸了。(创建了一个没有“..”的单独导航包含)

我认为可能是一个解决方案:不要使用 index.php 文件主目录,而是创建一个名为 home 的目录并将索引文件放在那里,这样一切都会顺利进行。(public_html/home/index.php vs public_html/index.php)(不确定如何与域一起工作)

我还查看了绝对链接和相对链接,但它们最终在我的计算机上工作然后上传它们变得一团糟?

任何人都有可以提供帮助的想法?

更新:这样的东西有用吗?

# Turn on rewrites.
RewriteEngine on

# Only apply to URLs on this domain
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$

# Only apply to URLs that aren't already under folder.
RewriteCond %{REQUEST_URI} !^/folder/

# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all those to insert /folder.
RewriteRule ^(.*)$ /folder/$1

# Also redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ folder/index.php [L]
4

0 回答 0