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
https://forums.phpfreaks.com/topic/39927-php-and-mod_rewrite-problem/
Share on other sites

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

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