Forum Moderators: phranque
Example URLs of my site would be:
[domain.com...]
[domain.com...]
I would like them to appear:
[domain.com...] (or .html)
[domain.com...]
But here's where my bi-directional question comes in: Is it possible to use mod-rewrite to have my links within my document appear as:
<a href="home.php">home</a>
instead of current:
<a href="index.php?page=home">home</a>
Or, because of the $_GET'[page] factor in PHP is that not possible? Here's my PHP dynamic page code if that helps:
<?php
if(isset($_GET['page'])) {
include("{$page}/index.php");
print($page);
}
else {include('home/index.php');
}
?>
Would this need to be changed to accomplish what I'm trying to do?
BTW, I tried tackling this myself but didn't get very far. Because each page variable changes, I got confused:
RewriteEngine on
RewriteRule ^index\.php$ newlink.php [R=301,L]
Bek
the mod_rewrite code would look like this
RewriteEngine on
RewriteRule ^(.*).html$ index.php?page=$1 [R]
The basic approach is to "manually" change the links on your pages to "friendly" format. Do this in your script that produces the pages. This friendly format is then what users and SE spiders will see when they fetch the pages, bookmark them, link to them, and list them in search results.
Then on the front end of requests to your server, use mod_rewrite in .htaccess or in httpd.conf to grab the requested URL, and change it back to the format that your script needs. With a small but important change, that's what the code posted above does:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)\.html$ index.php?page=$1 [L]
Jim
[webmasterworld.com...]