|
#1
|
||||
|
||||
|
hi all
I can't get this mod rewrite thingy to work with my site ![]() Strange thing is my little test script works, but it wont work with my main wallpaper outputting system (full of bugs probably but I wrote it myself from scratch and i'm proud of it ok )ok so here is the htaccess in full: Code:
# error pages ErrorDocument 404 /404error.htm ErrorDocument 403 /403error.htm #rewrite download urls Options +FollowSymlinks RewriteEngine on RewriteRule ^c96/(.+) /wallpapers/cars96/$1 [nc] RewriteRule ^c101/(.+) /wallpapers/cars101/$1 [nc] RewriteRule ^c120/(.+) /wallpapers/cars120/$1 [nc] RewriteRule ^c128/(.+) /wallpapers/cars128/$1 [nc] RewriteRule ^c160/(.+) /wallpapers/cars160/$1 [nc] RewriteRule ^c174/(.+) /wallpapers/cars174/$1 [nc] RewriteRule ^c176/(.+) /wallpapers/cars176/$1 [nc] RewriteRule ^c240/(.+) /wallpapers/cars240/$1 [nc] RewriteRule ^f96/(.+) /wallpapers/flags96/$1 [nc] RewriteRule ^f101/(.+) /wallpapers/flags101/$1 [nc] RewriteRule ^f120/(.+) /wallpapers/flags120/$1 [nc] RewriteRule ^f128/(.+) /wallpapers/flags128/$1 [nc] RewriteRule ^f160/(.+) /wallpapers/flags160/$1 [nc] RewriteRule ^f174/(.+) /wallpapers/flags174/$1 [nc] RewriteRule ^f176/(.+) /wallpapers/flags176/$1 [nc] RewriteRule ^f240/(.+) /wallpapers/flags240/$1 [nc] RewriteRule ^m96/(.+) /wallpapers/misc96/$1 [nc] RewriteRule ^m101/(.+) /wallpapers/misc101/$1 [nc] RewriteRule ^m120/(.+) /wallpapers/misc120/$1 [nc] RewriteRule ^m128/(.+) /wallpapers/misc128/$1 [nc] RewriteRule ^m160/(.+) /wallpapers/misc160/$1 [nc] RewriteRule ^m174/(.+) /wallpapers/misc174/$1 [nc] RewriteRule ^m176/(.+) /wallpapers/misc176/$1 [nc] RewriteRule ^m240/(.+) /wallpapers/misc240/$1 [nc] RewriteRule ^t96/(.+) /wallpapers/cartoons96/$1 [nc] RewriteRule ^t101/(.+) /wallpapers/cartoons101/$1 [nc] RewriteRule ^t120/(.+) /wallpapers/cartoons120/$1 [nc] RewriteRule ^t128/(.+) /wallpapers/cartoons128/$1 [nc] RewriteRule ^t160/(.+) /wallpapers/cartoons160/$1 [nc] RewriteRule ^t174/(.+) /wallpapers/cartoons174/$1 [nc] RewriteRule ^t176/(.+) /wallpapers/cartoons176/$1 [nc] RewriteRule ^t240/(.+) /wallpapers/cartoons240/$1 [nc] #this test works works RewriteRule ^test/(.+)/(.+) /test.php?id=$1&nm=$2 [nc] #this is the problem area RewriteRule ^wallpaper/(.+)/(.+)/(.+) /wallpaper.php?id=$1&cat=$2&size=$3 [nc] #stop showing .inc contents <Files *.inc> order allow,deny deny from all </Files> # move old pages Redirect 301 /cars128.php http://www.free-mobile.net/wallpaper.php?cat=cars&size=128 Redirect 301 /misc128.php http://www.free-mobile.net/wallpaper.php?cat=misc&size=128 Redirect 301 /cartoons128.php http://www.free-mobile.net/wallpaper.php?cat=cartoons&size=128 http://www.free-mobile.net/test/one/two and code: Code:
<html> <head> <title>Test Page</title> </head> <body> ID: <strong><?php echo $_GET['id'] ?></strong> <br /> NM: <strong><?php echo $_GET['nm'] ?></strong> <br /> </body> </html> http://www.free-mobile.net/wallpaper/1/cars/128 php doesn't see the variables in the url and reverts to the defaults I put in ![]() source for that is really long and in two main parts so ive put it in a txt files here (wallpaper.php): http://www.free-mobile.net/external/cthwallpaper.txt and here (gallery/main.php): http://www.free-mobile.net/external/cthmain.txt Phew! Thanks in advance!
__________________
Free Mobile Phone Wallpapers |
|
#2
|
||||
|
||||
|
The rule seems fine. It is your links that you haven't coded correctly.
You need to change them to suite the rule. e.g. Code:
<img src="wallpapers/misc128/bm_greensmear.jpg" class="link1" alt="misc wallpaper 0" title="free misc wallpaper 0"/> Code:
http://www.free-mobile.net/wallpaper/1/cars/128/wallpapers/misc128/bm_greensmear.jpg What you want is a link to Code:
http://www.free-mobile.net/wallpapers/misc128/bm_greensmear.jpg Code:
<img src="/wallpapers/misc128/bm_greensmear.jpg" class="link1" alt="misc wallpaper 0" title="free misc wallpaper 0"/> Do that same for your links. Code:
<a href="window.php?id=0&cat=misc&size=128">
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#3
|
||||
|
||||
|
thanks
yeah I know i'd have to change the links but right now going directly to this url: http://www.free-mobile.net/wallpaper/1/cars/128 doesn't work as the GET command doesn't seem to work and instead it's using the rule I put in to make the default page 1, misc catigory and size 128
__________________
Free Mobile Phone Wallpapers |
|
#4
|
||||
|
||||
|
As far as I can see it is working. It is bringing up the same page as
http://www.free-mobile.net/wallpaper...=cars&size=128 But because your links are wrong the CSS or images are not being loaded. Code:
<link rel="stylesheet" href="css/site.css" /> Code:
http://www.free-mobile.net/wallpaper/1/cars/128/css/site.css What you want is Code:
<link rel="stylesheet" href="/css/site.css" /> Sp that the link is Code:
http://www.free-mobile.net/css/site.css
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#5
|
||||
|
||||
|
Just noticed that the content is not exact. Fix the links first so we have a proper comparison.
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#6
|
||||
|
||||
|
Quote:
fixed the link to the css so the page is styled, although that wouldn't be an issue if the rewrite and php was working ala the test i did
__________________
Free Mobile Phone Wallpapers |
|
#7
|
||||
|
||||
|
You still haven't changed your URLs.
e.g. You are trying to show an image Code:
<img src="wallpapers/misc128/bm_greensmear.jpg" Code:
http://www.free-mobile.net/wallpaper/1/cars/wallpapers/misc128/bm_greensmear.jpg The source should be Code:
<img src="/wallpapers/misc128/bm_greensmear.jpg" You need to do the same with your hyperlinks. You need to replace your PHP code to point to the rewrite URL instead of the querystring. Code:
echo ("<a href=\"".$me."?id=".$fc."&cat=".$cat."&size=".$size."\">".$fc." </a> ");
http://www.free-mobile.net/wallpaper/1/cars/128
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#8
|
||||
|
||||
|
yes I realise that, however although the images will be dead links it should at least load up the cars page and not misc (the default) when you go to the example url above...
__________________
Free Mobile Phone Wallpapers |
|
#9
|
||||
|
||||
|
I know that is not your major problem, but it would be easier to see what is wrong if we can see the page how it should be, even though it is not grabbing the correct vars.
Have you tried removing your validation code. It seems that if you request a wrong URL it defaults to misc. Try removing that code to see what errors are output.
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#10
|
||||
|
||||
|
ok ive tried removing the validation for cat and page as well as the check to make sure the cat is allowed (stops some hacks) and get:
Warning: opendir(wallpapers/128/): failed to open dir: No such file or directory in /home/www/freenmob/gallery/main.php on line 17 1/0 (Number of wallpapers 0) Next Page Pages: Warning: Invalid argument supplied for foreach() in /home/www/freenmob/gallery/main.php on line 56 im assuming thats because php finds nothing in the vars so can't open a blank folder... I can't really adjust the links because the script is live on my site and doing so will break things which work just now (with the long urls) I then tried not using the include and putting the whole thing into the wallpaper.php file: Code:
<?php
require("gallery/cats_config.inc"); // includes config file
require("layout/top.txt");
$cat = $_GET['cat']; //gets category of wallpaper
$size = $_GET['size']; //gets size of wallpaper
if (!isset($_GET['cat'])) { //what to do if there is no cat
$cat = "misc";
}
if (!isset($_GET['size'])) { //what to do if there is no size
$size = "128";
}
$h1name = $h1names[$cat];
$h1size = $h1sizes[$size];
?>
<meta name="keywords" content="<?php echo($h1name.", ".$h1size); ?>, free, mobile, wallpaper, wallpapers, wap" />
<meta name="description" content="Free <?php echo($h1name." ".$h1size); ?> colour wallpapers for mobile phones." />
<meta name="robots"content="index,follow" />
<meta name="copyright" content="Copyright 2004-2006 free-mobile.net. All Rights Reserved." />
<title><?php echo($h1name." ".$h1size); ?> @ <?php include("layout/title.txt"); ?> </title>
<?php include("layout/masthead.txt");
include("layout/sidebar.txt");
//protection for cat and size
if (in_array($cat, $pass) && in_array($size, $pass_size)) {
?>
<h1><?php echo($h1name." ".$h1size); ?></h1>
<?php
//include ("gallery/main.php");
/*All this is Copyright 2006 Colin Symon (for free-mobile.net)
You may use/modify it but you MUST leave a clearly visible link back to free-mobile.net on any pages this script
is used on. */
//version 0.3 13/06/06
$realname = $_GET['id']; //gets visible id
if (!isset($_GET['id'])) { //what to do if there is no id
$realname = 1;
}
require("gallery/gallery_config.inc"); // includes config file
require("gallery/cats_config.inc"); // includes config file
require("gallery/ad_config.inc"); //gets ad for mid gallery
$name = $realname*$notopage; //works out hidden name for images on page
$filecount = 0; //sets file counter
//this opens the folder and reads in the images. Counts the total number as well.
if ($handle = opendir($images)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && (substr(strtolower($file),-3) == 'jpg')) {
$files[] = $file;
if ($sort == "decending"){
rsort($files);
}
$filecount++;
}
}
closedir($handle);
}
$rawpage = $filecount/$notopage; //how many pages not rounded
$pages = round($rawpage+0.5); // how many pages rounded up
if ($rawpage == $pages-1){ //0.2 smart fix for rounding up bug if raw pages is a whole number
$pages = $rawpage;
}
echo ("<p>");
if ($realname != 1){
echo ("<span style=\"font-weight:bold;\"><a href=\"".$me."?id=".($realname-1)."&cat=".$cat."&size=".$size."\">Previous Page </a></span>");
}
echo (" ".$realname."/" .$pages);
echo (" (Number of wallpapers " .$filecount. ") ");
if ($realname != $pages){
echo ("<span style=\"font-weight:bold;\"><a href=\"".$me."?id=".($realname+1)."&cat=".$cat."&size=".$size."\">Next Page</a></span>");
}
echo ("</p><p><span style=\"font-weight:bold;\">Pages: ");
$fc = 1;
while ($fc <= $pages) {
echo ("<a href=\"".$me."?id=".$fc."&cat=".$cat."&size=".$size."\">".$fc." </a> ");
$fc++;
}
echo ("</span></p>");
$colCtr = 0; //gets the trs in the right place
$counter = 0; //which images to appear on this page is based on this value
$rowcount = 0; //gets row number to insert ad
//display the table
echo ("<table class=\"gallery\"><tr class=\"gallery\"><td></td>" . "\n");
foreach($files as $file )
{
if ($counter > ($name-$notopage-1) && $counter < $name){
if($colCtr %$cols == 0) {
if ($rowcount == 1){
echo ("</tr><tr><td colspan=\"". $cols ."\"><div class=\"center\"><div class=\"centered\">".$ad."</div></div></td></tr><tr>" . "\n");
$rowcount++;
}
else{
echo ("</tr><tr><td colspan=\"". $cols ."\"></td></tr><tr>" . "\n");
$rowcount++;
}
}
echo ("<td class=\"gallery\"><a href=\"window.php?id=" .$counter."&cat=".$cat."&size=".$size."\"><img src=\"" . $images . $file . "\" class=\"link1\" alt=\"".$cat." wallpaper ".$counter."\" title=\"free ".$cat." wallpaper ".$counter."\"/></a> </td>" . "\n");
$colCtr++;
$counter++;
}
else {
$counter++; //have to keep counter running or the page 1 images will always appear
}
}
echo ("</tr></table>");
//end
}
else {
echo("<h1>Bad Request</h1>Please use the links provided.");
}
include("layout/rightside.txt");
include("layout/footer.txt"); ?>
__________________
Free Mobile Phone Wallpapers Last edited by 30111987; July 17th, 2006 at 09:25 PM. |
|
#11
|
||||
|
||||
|
Quote:
Look into Split or Explode
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#12
|
||||
|
||||
|
hmm
that is strage tho because it works fine with my test script...
__________________
Free Mobile Phone Wallpapers |
|
#13
|
||||
|
||||
|
The only other thing I could suggest is to start from strach on your gallery script to see where it breaks.
Your rewrite rule seems fine. Back to basics. Have you tried a foreach loop through $_GET to see what vars you are getting?
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#14
|
||||
|
||||
|
eh...
I have tried a basic echo ($_GET['cat']); it outputs nothing ![]() im going to setup a test server on my pc and see if it's possibly the web-mania server at fault
__________________
Free Mobile Phone Wallpapers |
|
#15
|
||||
|
||||
|
Put this code after the body tag
PHP Code:
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
![]() |
| Bookmarks |
«
Previous Topic
|
Next Topic
»
| Topic Tools | |
|
|
All times are GMT +1. The time now is 01:26 PM.
[
RSS ]




)




