Jump to content

PHP and mod_rewrite problem...


cwncool

Recommended Posts

I'm making a script that when $_GET['?'] is set, it redirects to a page, from a database, related to the ID set in the url.  Like, if it was http://mysite.com/??=df48 or whatever, it looks that up in a database, and redirects to a page.  I'm trying to use modrewrite, so I can have a url like this: http://mysite.com/df48 , and it to then redirect.  Without the mod_rewrite's .htaccess file on my server, I can call http://mysite.com/??=df48 and it redirects properly.  When I do have the mod_rewrite's .htaccess though, neither http://mysite.com/df48 OR  http://mysite.com/??=df48 works.  It doesn't execute the code related to the $_GET variable with the .htaccess file.  I don't know why it doesn't execute that code any more, regardless if the $_GET is even in the url. Can someone please help me?  These are my two codes:

 

PHP:

<? 
if(isset($_GET['?'])) {
$id2 = $_GET['?'];
$look = mysql_query("SELECT * FROM urls WHERE id2='$id2'");
$look = mysql_fetch_array($look);
$url = $look['url'];
$hits = $look['hits']+1;
mysql_query("UPDATE urls SET hits='$hits' WHERE id2='$id2'");
header("location:$url");
}
?>

 

.htaccess:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} \.css$
RewriteRule ^.*$ style.css [L]
RewriteRule (.*) index.php??=$1

 

Thanks!

Link to comment
Share on other sites

  • 1 month later...
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.