这将是一篇很长的帖子,所以请耐心等待。
这是我的目录结构
public_html
agentc0re
blog
重写规则已启用并正在工作。
重写public_html-hide agentc0re的规则并重定向到index.php
public_html.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?agentc0re.com$ [NC]
RewriteCond %{REQUEST_URI} !^/agentc0re/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /agentc0re/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?agentc0re.com$ [NC]
RewriteRule ^(/)?$ agentc0re/index.php [L]
</IfModule>
我的index.php是这样设计的,它加载特定的页面&然后是我的页眉,这样我每一页都有我的菜单。
http://domain.com/index.php
<?php
if(isset($_GET['page'])) {$page = $_GET['page']; /* gets the variable $page */}
//else{$page = 'index.php';}
if (!empty($page)) {
$page .= '.php';
include($page);
} /* if $page has a value, include it */
else {
include('home.php');
} /* otherwise, include the default page */
include 'header.php';
?>
这导致加载页面,http://domain.com/index.php?page=(博客|论坛|…等)
我的agentc0re文件夹具有以下重写规则,因此它仅用http://domain.com/(博客|论坛等)
/agentc0re/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /agentc0re/
RewriteCond %{HTTP_HOST} ^(www'.)?agentc0re'.com$ [NC]
RewriteCond %{THE_REQUEST} 's/(index'.php)?['s?] [NC]
RewriteRule ^ /Home? [R=301,L]
RewriteRule ^Home/?$ /index.php?page= [L]
RewriteRule ^Blog/?$ /index.php?page=blog [L]
RewriteRule ^Forum/?$ /index.php?page=forum [L]
RewriteRule ^SubCounter/?$ /index.php?page=SubCounter/subCounter [L]
RewriteRule ^AboutMe/?$ /index.php?page=aboutme [L]
RewriteRule ^Contact/?$ /index.php?page=contact [L]
</IfModule>
你看,我只是使用游戏的大写版本来区分实际页面,IE blog.php AKA blog(哦,是的,忘了提到我上面的php代码删除了.php,所以我不需要在重写规则中添加它)
所以现在,http://domain.com/Blog作品格式很糟糕,但不管怎样。
问题出在这里
漂亮的永久链接在启用时不起作用。
/agentc0re/blog/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index'.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
我想要的结果
当你浏览或点击将带你到这里的链接时:
http://domain.com/Blog/admin/whats-up-world/
工作并转到标题为";whats up world"我在wordpress中的漂亮永久链接设置为:
http://domain.com/Blog/%author%/%pagename%/
好吧,我想这本书已经写完了。如果你需要更多信息,请告诉我。
通过Godaddy托管,如果有任何帮助的话。
谢谢!!-Jon
编辑1
我忘了我应该添加两个可能与该问题相关的设置。
Wordpress URL: http://domain.com/agentc0re/blog
Site URL: http://domain.com/Blog
编辑2
只是意识到,当你点击菜单链接时,它会";双";这是一个新的环节。IE:你先加载http://domain.com/然后你就可以看到主页了。然后你点击博客。它会让你http://domain.com/Blog,但现在菜单栏中的所有内容都表示将链接到您所做的http://domain.com/Blog/(主页|博客等)。我不明白,所以我接受了/agentc0re/.htaccess的所有重写规则,并暂时将其注释掉。
为了获得漂亮的perma链接来使用我的设置,我只需要做以下超级简单的更改。
我的wordpress.htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index'.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ../index.php?page=blog [L,NC]
</IfModule>
只需要将最后一行更改为MY index.php,它包含了我的标题/菜单等所有内容。
还有一些问题没有解决,但我认为这个问题已经得到了解决,因为我当时的主要问题是弄清楚如何让Pretty Permalinks与我的网站协同工作。