FreePgs.com Forum

FreePgs Related => Support Requests => Topic started by: Dondavid on March 20, 2006, 08:50:12 AM

Title: URL Rewriting problems...
Post by: Dondavid on March 20, 2006, 08:50:12 AM
Hi,

I'd like to use URL Rewriting to point links like this one:
http://www.creersonsite.fr.nf/cours/PHP/sommaire.php
to this:
http://www.creersonsite.fr.nf/index.php?cours=PHP&id=sommaire

So in my .htaccess file I wrote:
RewriteRule ^/cours/PHP/([^/]*)\.php$ /index.php?cours=PHP&id=$1 [L]

but it doesn't work, seems like the variables put in the URL do not exist. And I don't understand why.
Do anyne know why?

Thanks
PS: Sorry my English is not very good.
Title: Re: URL Rewriting problems...
Post by: Dondavid on March 20, 2006, 08:53:47 AM
OOPS, Sorry for multiple post. I don't understand what happened.
Title: Re: URL Rewriting problems...
Post by: Ben on March 20, 2006, 06:12:42 PM
Multiple Posts deleted.

And I'm not the best with .htaccess files, but you can try this:

RewriteRule ^/cours/PHP/([A-Za-z0-9-]*)\.php$ /index.php?cours=PHP&id=$1 [L]

Title: Re: URL Rewriting problems...
Post by: Dondavid on March 20, 2006, 08:01:04 PM
Thanks for deleting, I feel so stupid...

Your piece of code seems to not work. I must say I don't understand why, and this is drivin' me crazy.
Thanks for your suggestion anyway...
Title: Re: URL Rewriting problems...
Post by: webzone (archived) on March 20, 2006, 08:51:31 PM
The RewriteRule is not applied because the request doesn't match the pattern. Patterns never match if they start with a /.

This one should work, however:
RewriteRule ^cours/(PHP)/([^/]*)\.php$ index.php?cours=$1&id=$2 [L]
Title: Re: URL Rewriting problems...
Post by: Dondavid on March 21, 2006, 04:17:49 PM
Ok, I didn't know that. Your piece of code doesn't work too.
I really begin to wonder if it's possible.
Title: Re: URL Rewriting problems...
Post by: Dondavid on March 21, 2006, 10:17:03 PM
Problem Solved!!!!!!!
The correct rule is:
RewriteRule ^cours/(PHP|JS|XHTML|CSS)/(.+)\.(php|html)$ index.php?cours=$1&id=$2 [L]

Don't ask me why I don't know. (lol)

thanks to all who tried.