I have tied a couple things to get this to work and no matter what it will not, please someone help me.
I have a site lets call it example.com
on the site I have a href links that look like this
<a href="http://www.example.com/index.php?page=My_Home_Page">HOME</a>
<a href="http://www.example.com/index.php?page=My_About_Page">ABOUT</a>
To display the correct content on the correct page when each link is clicked I am using this
PHP Code:
<?php
$nav = $_GET['page']; //gets the variable inside page query string and stores it into the variable $nav
if (!isset ($_GET['page'])){
$nav = "My_Home_Page"; //if no query string is available then use the data from "My_Home_Page"
}
if ($nav == 'My_Home_Page'){ //if the query string is equal to "My_Home_Page" then display the following
?>
<!-- BREAK OUT OF PHP TO ENTER HTML -->
<H1>HOME</H1>
<!-- RETURN TO PHP -->
<?php
}
else if ($nav == 'My_About_Page'){ //if the query string is equal to "My_About_Page" then display the following
?>
<!-- BREAK OUT OF PHP TO ENTER HTML -->
<H1>ABOUT</H1>
<!-- RETURN TO PHP -->
<?php
}
Now this is all working and has been for a while however now I am trying to do some seo and I would like to rewrite all my urls to be more seo friendly, so I am on an apache server for my hosting so I figure I would use the .htaccess file.
This is my .htaccess file
Code:
Options +FollowSymLinks
Options -Indexes
RewriteEngine on
# THIS PART IS WORKING IF I ENTER http://example.com IT ADDS THE www to be http://www.example.com
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
# THIS IS NOT WORKING
RewriteRule http://www.example.com/index.php?page=My_Home_Page http://www.example.com/SEO-Home-Page-with-nice-keywords
RewriteRule http://www.example.com/index.php?page=My_About_Page http://www.example.com/SEO-About-Page-with-nice-keywords
# I HAVE NO IDEA IF THIS IS WORKING OR NOT MY ISP TOLD ME TO ENTER THIS BECAUSE I KEPT GETTING OLD CONTENT
# APPARENTLY THIS EXPIRES THE CACHE AFTER ONLY 1 MINUTE
<FilesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>
I now assume that if I am on my site and I click on the about page link, it should take me to the about pages content, however my url should now be
http://www.example.com/SEO-About-Pag...-nice-keywords
this is not working though it just shows me the content of the about page and the url remains as it always was with the php query string
The other part is working though, when I type in the url without a www, it adds it in for me.
Please help.