Log in

View Full Version : Resolved mod_rewrite



jr_yeo
11-01-2009, 11:52 AM
how to make URLs look like hxxp://localhost/site/picture.html instead of /site/index.php?p=picture.jpg? tnx.

here is the code that im working with and i can't seem to figure it out....


<?php $albumName = "some title here"; // Name your album!
$p = $_GET['p'];
if ($handle = opendir("images")) {
$i = 1;
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$img[$i] = $file;
if ($p == $img[$i]) {
$ci = $i;
}
$i++;
}
}
closedir($handle);
$ti = $i - 1;
$pi = $ci - 1;
if ($p == "") {
$ni = $ci + 2;
} else {
$ni = $ci + 1;
}
$prevNext = "";
if ($pi > 0) {
$piFile = $img[$pi];
$prevNext .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=" . $piFile . "\" title=\"show previous image\">«</a>";
} else {
$prevNext .= "«";
}
$prevNext .= " | ";
if ($ni <= $ti) {
$niFile = $img[$ni];
$prevNext .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=" . $niFile . "\" title=\"show next image\">»</a>";
} else {
$prevNext .= "»";
}
if ($p == "") {
$p = $img[1];
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo $albumName; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="imagetoolbar" content="no">
</head>
<body>
<h1><?php echo $albumName; ?></h1>
<div class="hRule"></div>
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr align="center">
<td class="nextPrevious"><?php echo $prevNext; ?></td>
</tr>
<tr align="center">
<td><img src="images/<?php echo $p; ?>" alt="<?php echo $$albumName; ?>" border="0"></td>
</tr>
</table>
<p>some other text here</p>
</body>
</html>


tnx.

newbtophp
11-04-2009, 04:22 AM
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_URI} !^.*\.
RewriteRule ^(.*)$ index.php?p=$1

prasanthmj
11-04-2009, 04:34 AM
You should have Apache webserver and mode_rewrite must be enabled for this to work.

Create a file named .htaccess in the folder /site/

edit .htaccess and update the contents:


Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ index.php?p=$1.jpg [NC]
RewriteRule ^$ index.php [NC]

jr_yeo
11-04-2009, 02:34 PM
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ index.php?p=$1.(gif|jpg|png|bmp)$ [NC]
RewriteRule ^$ index.php [NC]

will something this work also? notice the highlight.

thnx.

jr_yeo
11-07-2009, 02:36 AM
You should have Apache webserver and mode_rewrite must be enabled for this to work.

Create a file named .htaccess in the folder /site/

edit .htaccess and update the contents:


Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html$ index.php?p=$1.jpg [NC]
RewriteRule ^$ index.php [NC]


tried that. still didn't get the desired result. tnx though.

jr_yeo
11-16-2009, 05:47 PM
how to put "RESOLVED" in my thread?

Snookerman
11-16-2009, 07:49 PM
You can go to your first post in the thread, click http://www.dynamicdrive.com/forums/images/buttons/edit.gif then click Go Advanced and add the Resolved prefix to the thread title.

Happy foruming!

jr_yeo
11-17-2009, 03:41 AM
looked into that. didn't see any EDIT button to click. ^_^

Snookerman
11-17-2009, 08:15 AM
For some reason it disappears after some time.. vBulletin..
I'll do it for you.