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! Link to comment https://forums.phpfreaks.com/topic/39927-php-and-mod_rewrite-problem/ 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] Link to comment https://forums.phpfreaks.com/topic/39927-php-and-mod_rewrite-problem/#findComment-193012 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... Link to comment https://forums.phpfreaks.com/topic/39927-php-and-mod_rewrite-problem/#findComment-193018 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. Link to comment https://forums.phpfreaks.com/topic/39927-php-and-mod_rewrite-problem/#findComment-193031 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? Link to comment https://forums.phpfreaks.com/topic/39927-php-and-mod_rewrite-problem/#findComment-193063 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 / ? Link to comment https://forums.phpfreaks.com/topic/39927-php-and-mod_rewrite-problem/#findComment-193407 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. Link to comment https://forums.phpfreaks.com/topic/39927-php-and-mod_rewrite-problem/#findComment-231265 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.