acegames Posted February 25, 2009 Share Posted February 25, 2009 Hello , I cant seem to get this to work properly , can anyone suggest what I have done wrong Options FollowSymLinks RewriteEngine On RewriteRule ^download-([^/-]+)-([^/-]+)-([^/-]+)-([^/-]+)-([^/-]+)\.html$ download.php?=$1&id=$2&table=$3&filename=$4&page=$5& [L,NC] This is the original url http://domain.com/download.php?&id=669&table=3gp&filename=Narc&page=/download.php Quote Link to comment Share on other sites More sharing options...
acegames Posted February 26, 2009 Author Share Posted February 26, 2009 Ok , I have tested and mod_rewrite is 100% working on the server I just cant get the mod_rewrite to work for me This is my structure : download.php?id=733&table=3gp&filename=Shameless+007th+Heaven&page=/free-3gp-video-download.php Can anyone give me any pointers as to why any mod_rewrite I try for the above does nothing ? Quote Link to comment Share on other sites More sharing options...
cabofixe Posted February 26, 2009 Share Posted February 26, 2009 I'm kinda new and I don't know if this will change much but I've heard the first line should be: Options +FollowSymlinks Second, are you sure mod_rewrite is configured on your server? Try adding some dummy code in your .htaccess file like: RewriteGARBAGE THIS WON'T WORK If your .htaccess file is working then when you go to the site you will get a 500 Internal Server error. Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted February 27, 2009 Share Posted February 27, 2009 I am not familiar with mod_rewrite, but I am with (PCRE) regex.. So I have to look at this link to make sure I understand the subtle differences between the two (namely the dash -). I am looking at your pattern: ^download-([^/-]+)-([^/-]+)-([^/-]+)-([^/-]+)-([^/-]+)\.html$ Your pattern looks for .html at the end, yet the string you are plugging in is .php. Surely that must be one cause. The other thing I am noticing is that the amount of captures exceeds what can be captured in your string, as there is nothing optional.. it all requires (one or more times). I would check to make sure that you don't have excessive amounts of captured flying around, and make sure the file extension the pattern is looking for matches what you are checking against. Quote Link to comment Share on other sites More sharing options...
acegames Posted February 27, 2009 Author Share Posted February 27, 2009 I'm kinda new and I don't know if this will change much but I've heard the first line should be: Options +FollowSymlinks Second, are you sure mod_rewrite is configured on your server? Try adding some dummy code in your .htaccess file like: RewriteGARBAGE THIS WON'T WORK If your .htaccess file is working then when you go to the site you will get a 500 Internal Server error. Yes mod_rewrite is 100% working on the server , I did a .htaccess test wit hgoogle it redirected , and with two html files one called bob one called alice from a test I saw on a web and that worked Quote Link to comment Share on other sites More sharing options...
acegames Posted February 27, 2009 Author Share Posted February 27, 2009 I am not familiar with mod_rewrite, but I am with (PCRE) regex.. So I have to look at this link to make sure I understand the subtle differences between the two (namely the dash -). I am looking at your pattern: ^download-([^/-]+)-([^/-]+)-([^/-]+)-([^/-]+)-([^/-]+)\.html$ Your pattern looks for .html at the end, yet the string you are plugging in is .php. Surely that must be one cause. The other thing I am noticing is that the amount of captures exceeds what can be captured in your string, as there is nothing optional.. it all requires (one or more times). I would check to make sure that you don't have excessive amounts of captured flying around, and make sure the file extension the pattern is looking for matches what you are checking against. I will try that but I thought the first part is what it converts it to and the second half with download.php is what it is originally ? Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted February 27, 2009 Share Posted February 27, 2009 You are right in the the first half is converted to the second half.. but look at what your first half is looking for... it is looking for a .html file.. if you are using a .php file to begin with, this alone fails the pattern. Quote Link to comment Share on other sites More sharing options...
acegames Posted February 27, 2009 Author Share Posted February 27, 2009 Changed it to this : Options FollowSymLinks RewriteEngine On RewriteRule ^download-([^/-]+)-([^/-]+)-([^/-]+)-([^/-]+)-([^/-]+)\.php?$ download.php?=$1&id=$2&table=$3&filename=$4&page=$5& [L,NC] Dynamic url is this : download.php?id=733&table=3gp&filename=Shameless+007th+Heaven&page=/free-3gp-video-download.php And still nothing changes at all ??? Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted February 27, 2009 Share Posted February 27, 2009 No, that won't work, because you have 5 sets of capture ([^/-]+). For this pattern to succeed, you need to fullful those 5 captures.. but if you look at what they are asking for (anything that is not a / or - one or more times), this means that given your sample url: download.php?id=733&table=3gp&filename=Shameless+007th+Heaven&page=/free-3gp-video-download.php if you look at the first capture, it will match '.php?id=733&table=3gp&filename=Shameless+007th+Heaven&page=' (I am assuming from the previous link I included that the - inbetween all those pattern elements are checking to see if those files/directories exist (again, I'm more familiar with PCRE regex than mod_rewrite regex). In anycase, as you can see, just the one capture eats up most of your string (there are still 4 others that need to be met, yet there is no way those other 4 will be met). Could you post as a single string what you want to see done to your dynamic URL string? So in other words, if you start with: download.php?id=733&table=3gp&filename=Shameless+007th+Heaven&page=/free-3gp-video-download.php What would the final string look like in accordance to what you want to see? (never mind the regex for the moment... just type out the final URL string to this example that you are looking for). Quote Link to comment Share on other sites More sharing options...
acegames Posted February 27, 2009 Author Share Posted February 27, 2009 No, that won't work, because you have 5 sets of capture ([^/-]+). For this pattern to succeed, you need to fullful those 5 captures.. but if you look at what they are asking for (anything that is not a / or - one or more times), this means that given your sample url: download.php?id=733&table=3gp&filename=Shameless+007th+Heaven&page=/free-3gp-video-download.php if you look at the first capture, it will match '.php?id=733&table=3gp&filename=Shameless+007th+Heaven&page=' (I am assuming from the previous link I included that the - inbetween all those pattern elements are checking to see if those files/directories exist (again, I'm more familiar with PCRE regex than mod_rewrite regex). In anycase, as you can see, just the one capture eats up most of your string (there are still 4 others that need to be met, yet there is no way those other 4 will be met). Could you post as a single string what you want to see done to your dynamic URL string? So in other words, if you start with: download.php?id=733&table=3gp&filename=Shameless+007th+Heaven&page=/free-3gp-video-download.php What would the final string look like in accordance to what you want to see? (never mind the regex for the moment... just type out the final URL string to this example that you are looking for). Thanks for the reply , I just want the url to look something neater like : download.php/733/Shameless+007th+Heaven Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted February 27, 2009 Share Posted February 27, 2009 So would something like this work? RewriteEngine On RewriteRule download\.php.*id=([^&]+).*filename=([^&]+).*$ download.php/$1/$2 [L,NC] Quote Link to comment Share on other sites More sharing options...
acegames Posted February 27, 2009 Author Share Posted February 27, 2009 So would something like this work? RewriteEngine On RewriteRule download\.php.*id=([^&]+).*filename=([^&]+).*$ download.php/$1/$2 [L,NC] Sorry that did nothing at all ?? Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted February 27, 2009 Share Posted February 27, 2009 Just to be sure, is your .htaccess file in the proper folder (in this case, I'm guessing root of website)? It has to be in the proper location to be detected. Quote Link to comment Share on other sites More sharing options...
acegames Posted February 27, 2009 Author Share Posted February 27, 2009 Just to be sure, is your .htaccess file in the proper folder (in this case, I'm guessing root of website)? It has to be in the proper location to be detected. Yes its all correct , I did a test with two pages with a tutorial on the net and it worked fine , so mod_rewrite is working ok Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted February 27, 2009 Share Posted February 27, 2009 Then I'm at a loss unfortunately. Quote Link to comment Share on other sites More sharing options...
acegames Posted February 27, 2009 Author Share Posted February 27, 2009 Then I'm at a loss unfortunately. Yes me too , Thanks for your time on this one 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.