Jump to content

saariko

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

saariko's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I am trying to rewrite from: http://www.domain.com/a/VALUE to http://www.domain.com/a/p.php?id=VALUE I have tried the following, but nothing works RewriteBase / Rewritecond %{REQUEST_URI} !(^/a/*$) [NC] RewriteRule a/([0-9]+) /a/p.php?id=$1 [L] RewriteBase / RewriteRule ^a/(.*)$ a/p.php?id=$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain.com$ [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301] RewriteRule ^a/([A-Za-z0-9-]+)?$ a/p.php?id=$1 [NC] My .htaccess is in my http root folder, do I need to move it to my /a/ directory? and change the rules? If I try to play with the rules, and lets say do a redirect to : www.cnn.com it works, but I really need to rewrite for it to work. Thank you very much.
  2. *** First, if anyone can move this to the MOR_REWRITE, i will appreciate it. I don't want to double post. http://www.phpfreaks.com/forums/index.php/board,50.0.html *** Ok, I am still strugling on this, here is my last conf. My .htaccess is located on my root, and with the following tries (they are accesssed, because if for instance I will rewrite to: www.cnn.com it will work) RewriteBase / RewriteRule ^a/(.*)$ a/p.php?id=$1 [R=301,L] # RewriteCond %{HTTP_HOST} ^domain.com$ [NC] # RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301] # RewriteRule ^a/([A-Za-z0-9-]+)?$ a/p.php?id=$1 [NC] Do I need to move the .htaccess to my /a/ directory? and change the rules?
  3. Please update the new URL to: http://www.addedbytes.com/mod_rewrite_cheat_sheet.png
  4. Cheers for the quick reply, here are the settings I am trying on my .htaccess RewriteBase / Rewritecond %{REQUEST_URI} !(^/a/*$) [NC] RewriteRule a/([0-9]+) /a/p.php?id=$1 [L] I am trying to rewrite from: http://www.domain.com/a/VALUE to http://www.domain.com/a/p.php?id=VALUE however, it's not working. any ideas why ? appreciate your help
  5. Hi, What I am trying to do is transfer a _GET value to a default page, with as little URL naming as possible. I'll explain - I have a processing php file/page that gets values from the _GET of the URL. The output is a new redirect to an alternate page. The processing function takes the value: id=XXX, and according to the id redirects to XXX. What I am trying to do is: 1. not give the file name in the original address - succesfully done that by editing .htaccess DirectoryIndex directive. 2. transfer only 1 value in the calling address. So, if I call: www.site.com/a/[VALUE] I want my processing page to read the [VALUE] How can I do that? First trying to echo the vlaue (if I will be able to do that I am ok) <?php // Get a file into an array. In this example we'll go through HTTP to get // the HTML source of a URL. foreach($_REQUEST as $key => $value){ echo $value . "<br>";//You can for mat with HTML right here too }
  6. Just to let everyone know, I have solved this, please find the 3 files I use: 1. the values page is a comma seperated pair file. 2. the process page <?php // Get a file into an array. In this example we'll go through HTTP to get // the HTML source of a URL. $lines = file('values.inc'); // Loop through our array, show HTML source as HTML source; and line numbers too. foreach ($lines as $line_num => $line) { $pair = split (',' , $line); if ($pair[0] == $_GET['id']) Header("Location: " . $pair[1]); } the 3rd file, which does the work (and can be tweaked more) <html> <body> <?php $short = $_POST['shortname']; $redirect = $_POST['redirect']; ?> <form action="editlink.php" method="post"> <p>short name <input type="text" name="shortname" /><br /> re-direct to: COMPLETE ADDRESS PLEASE.<input type="text" name="redirect" /></p> For example:<br> short = help_en<br> re-direct = http://www.site.com/Help/en <br> The example gives you the option to use: http://www.site.com/pid.php?id=[sHORTVALUE]<br> and it will redirect you the the long url.<br> <p><input type="submit" value="Send it!"></p> </form> <?php $lines = file('values.inc'); $newval = true; echo "<P><B>You can send the first URL to the customer</B> <BR>"; foreach ($lines as $line_num => $line) { $pair = split (',' , $line); echo "http://www.site.com/pid.php?id=" . $pair[0] . "\t --> <a href='" . $pair[1] ."'>" . $pair[1] . " </a><BR>"; if ($pair[0] == $short) $newval = false; } if ( !empty($short) && $newval ) { $MyFile = fopen('values.inc', 'a+'); fwrite($MyFile, $short . "," . $redirect . "\n"); fclose($MyFile); $newval = false; } ?> </body> </html> Cheers, and thanks
  7. So I may have 3 files than values.inc (a simple text file, each entry is a line with comma) name1, url1 name2, url2 name3, url3 form.php to populate (might want to limit with regex to characers and number only, no special chars) and convert.php can simple go over the values.inc and take the second value. cheers, will try to work on that.
  8. Hi, As this is my first post here, I hope I can get the help I need. I am looking for a page/form to be able to edit one of our redirecting tables. Basiclly, we have a page: convert.php where the value entered in page=XXX , is getting redirected to an alternate page. The convert.php is: <?php #The address is: # it will use the variable "source" from the calling page. # please keep the table clean as possible #http://wwww.domain.com/convert.php?source= $redirecting_from=$_GET['source']; if($redirecting_from == "youtube"){ Header("Location: http://www.youtube.com/"); } elseif($redirecting_from == "cnn"){ Header("Location: http://www.cnn.com/"); } elseif($redirecting_from == "help_en"){ Header("Location: http://wwww.domain.com/Help/en/"); } elseif($redirecting_from == "test"){ Header("Location: http://wwww.domain.com/wszsmf"); } elseif($redirecting_from == "staff"){ Header("Location: http://wwww.domain.com/rxscwb"); } elseif($redirecting_from == "brochure"){ Header("Location: http://www.domain.com/files/2008Brochure_lowres.pdf"); } elseif($redirecting_from == ""){ Header("Location: "); }else { Header("Location: http://www.domain.com/"); } I want to give my users the ability to edit the name=value pairs, so they can do it on their own. They do not have access to my root, so the only/best option will be give them some php form to do it. Thanks p.s. After reading this, it looks like homework, well, it isn't. My domain is: http://www.optitex.com, and you can actually visit us :-)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.