Page 1 of 1

Question for url rewriting.

Posted: Sun May 08, 2011 8:46 pm
by MicroBoy
I do not know if this is the right place to do this question, but in a way PHP is used.Is possible to do this via .htaccess?

When a user writes:

Code: Select all

http://mysite.com/lajmet
The server will request:

Code: Select all

http://mysite.com/kategorit.php?kid=1
And when the user writes:

Code: Select all

http://mysite.com/lajmet/323
The server will request:

Code: Select all

http://mysite.com/kategorit.php?kid=1&lid=323

Re: Question for url rewriting.

Posted: Mon May 09, 2011 5:30 pm
by pickle
Yes, you can do that.

When the user requests mysite.com/lajmet, you can use .htaccess to rewrite that. However, you will need to hardcode each rule to map to a kid. For example, you will need one rule that maps "lajmet" to "kategorit.php?kid=1", another that maps "abcd" to "kategorit.php?kid=2", etc. OR, you can just redirect it to a PHP file & let the PHP file figure it out. The .htaccess rule would then redirect "mysite.com/lajmet" to "mysite.com/kategorit.php?name=lajmet". Your PHP file would then determine what kid the term "lajmet" refers to.