I am creating an SEO friendly page that works great as long as the final URL is still in the root directory.
http://www.domain.com/page.php?name=this-is-a-test -> http://www.domain.com/this-is-a-test
However, what I want is:
http://www.domain.com/page.php?name=this-is-a-test -> http://www.domain.com/page/this-is-a-test
I have a <base> element in the page and that works for the main stylesheet, but the included files (there are several) are still referencing the virtual directory it's now in (i.e. "/page/") and they don't have the correct paths.
Here is the code for the page. Any ideas how to get around this? I'd like to have separate pages for page.php (/page/seo-name), headline.php (/headline/seo-name) or headline.php (/headline/category/seo-name), giveaway (/giveaway/seo-name), etc.
.htaccess
Options +FollowSymLinks
RewriteEngine onRewriteBase /
# For Friendly URLs
RewriteRule ^page/([^/\.]+)/?$ page.php?name=$1
page.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" c />
<title><?php echo $site_title; ?></title>
<meta name="Keywords" c />
<meta name="Description" c />
<base href="<?php echo $base; ?>" />
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="wrapper-florets">
<div id="wrapper-main">
<?php
mxi_includes_start("inc_headernav.php");
require(basename("inc_headernav.php"));
mxi_includes_end();
?>
<div id="content">
<div id="home-main">
<div id="flash"></div>
<div id="general">
<div class="general-top">
<h1><?php echo $row_rsPage['title_page']; ?></h1>
</div>
<div class="general-bg"> <?php echo $row_rsPage['content_page']; ?> </div>
<div class="general-bottom"></div>
</div>
</div>
<div id="right">
<?php
mxi_includes_start("inc_rightall.php");
require(basename("inc_rightall.php"));
mxi_includes_end();
?>
</div>
</div>
<?php
mxi_includes_start("inc_footerads.php");
require(basename("inc_footerads.php"));
mxi_includes_end();
?>
</div>
<?php
mxi_includes_start("inc_footer.php");
require(basename("inc_footer.php"));
mxi_includes_end();
?>
</div>
</body>
</html>
I should also add that I know it's an issue with MX Includes and not wih the page coding itself.
I say this because everything works fine if I use a standard include and not the MX Include. Specifically, I believe it's an issue with the mxi_includes_start function.
This works
<?php
include("inc_headernav.php");
?>
This doesn't
<?php
mxi_includes_start("inc_headernav.php");
require(basename("inc_headernav.php"));
mxi_includes_end();
?>
I hope that helps. I did create a workaround, but I'd really like to get this to work as expected.
This is the workaround though.
I simply placed page.php and headline.php in a real folder called /seo. So the revised .htaccess file looks like this.
RewriteRule ^page/([^/\.]+)/?$ seo/page.php?name=$1
RewriteRule ^headline/([^/\.]+)/?$ seo/headline.php?name=$1
Thanks so much!