it is actually the opposite buddy, you rewrite the rules to take directories and transform them into .php?id=15 an example would be, user request mydomain.com/fish and the module will rewrite it to mydomain.com/mypage.php?category=fish, to have the actual id you would do something like mydomain.com/15/fish that would go for mydomain.com/mypage.php?id=15 – Prix Aug 18 '10 at 1:04
Can you help me with that then? rewrite the "directory" to "mypage.php?id=15" – Daniel t. Aug 18 '10 at 1:52
feedback

1 Answer

up vote 2 down vote accepted

Yeah, well, assuming the comment on your question is what you in fact want, you would do something like:

Somewhere on apache's config:

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

On your .htaccess:

RewriteEngine On
RewriteRule ^/directory/$ /mypage.php?id=something [NE,PT]

This would make it so that when you open http://mydomain.com/directory/ it would serve exactly the same content as http://mydomain.com/mypage.php?id=something.

Edit: fixed typo on RewriteEngine and fixed the regexp too... was distracted.

Hope this helps you.

link|improve this answer
this one generated internal server error. – Daniel t. Aug 18 '10 at 1:51
Do you have mod_rewrite on your apache config? Something like LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so. Oh I see the problem now... editing answer :P RewriteEngine not Rewire hehe! – Khai Aug 18 '10 at 2:12
I could go for a "rewire" engine for apache! – warren Aug 18 '10 at 2:55
when tested, removing the / preceding directory seems to work RewriteRule ^directory/$ /mypage.php?id=15 [NE,PT] – Daniel t. Aug 18 '10 at 5:35
That makes sense. Since you're putting the RewriteRule in a .htaccess file the RerwiteBase (baseline for all rewritten URLs) is automatically set to the directory where the .htaccess is. Generally I put my RewriteRules on the vhost definition and I keep the preceding / for readability instead of setting RewriteBase. – Khai Aug 18 '10 at 10:52
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.