Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/146797-mod_rewrite-not-working/
Share on other sites

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 ?

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.

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'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

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 ?

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.

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  ???

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).

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

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

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.