cwncool Posted February 24, 2007 Share Posted February 24, 2007 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! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 24, 2007 Share Posted February 24, 2007 Try this as the rewrite rule: RewriteRule ([A-Z0-9]+)/$ index.php??=$1 [NC] Quote Link to comment Share on other sites More sharing options...
cwncool Posted February 24, 2007 Author Share Posted February 24, 2007 I tried that, and it just gives me a directory not found error... Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 24, 2007 Share Posted February 24, 2007 Did you do http://mysite.com/df48/ NOTE: the ending forward slash at the end of the URL. Quote Link to comment Share on other sites More sharing options...
cwncool Posted February 24, 2007 Author Share Posted February 24, 2007 Okay. That works, but is there a way I can make it so it's not necessary for that to be on there? Quote Link to comment Share on other sites More sharing options...
cwncool Posted February 25, 2007 Author Share Posted February 25, 2007 Okay. That works, but is there a way I can make it so it's not necessary for that to be on there? No one know how I can change that rewrite rule, or add another one, so it works with or without the extra / ? Quote Link to comment Share on other sites More sharing options...
xdracox Posted April 17, 2007 Share Posted April 17, 2007 RewriteRule ([A-Z0-9]+)[/]?$ index.php??=$1 [NC] Might work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.