Jump to content

Recommended Posts

I have a shortner website that I am working on. Just a little project that I am doing in hopes that i can learn better.

 

Anyways my issue is that the shortened links are not working like they should. Actually they are not working at all. I keep getting a 404 page.

 

When I do something like shortit.org/123456 I get the 404 page.

 

shortit.org is the site that I am working on.

 

Here is the redirect code

<?php 
    include('function/init.php'); 
    if(isset($_GET['code']) && !empty($_GET['code'])) {
        $code = $_GET['code'];
        redirect($code);
        die();
    }
?>

 

 

here is the redirect function

function redirect($code){
    $code = mysql_real_escape_string($code);
    if(code_exists($code)){
        $url_query = mysql_query("SELECT `url` FROM `urls` WHERE `code` = '$code'") or die (mysql_error());
        $url = mysql_result($url_query, 0 , 'url');
        header('Location:' . $url);
    }
}

 

here is my .htaccess

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+)$ index.php?code=$1

 

Link to comment
https://forums.phpfreaks.com/topic/268634-htaccess-redirect-not-working/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.