Page 1 of 1

regex / mod_rewrite / .htaccess help

Posted: Thu Oct 30, 2008 12:21 pm
by alexandruc
Hello,

I am new with this stuff so please be gentle with me :)

I have this structure on my WAMP server with mod_rewrite enabled:
http://localhost/sitename/index.php
http://localhost/sitename/page.php?name=something
http://localhost/sitename/info.php?id=something-else

in the .htaccess i have the following code:

Code: Select all

Options +FollowSymLinks
RewriteEngine on
 
RewriteBase /
 
Rewriterule ^sitename/page/([^/])/?$ /sitename/page.php?name=$1 [L]
Rewriterule ^sitename/info/([^/])/?$ /sitename/info.php?id=$1 [L]
 
shouldn't it work?
accordingly with the information I found on the web and make the links like this:
http://localhost/sitename/page/something
http://localhost/sitename/info/something-else

What am I doing wrong? is there something missing from the .htacces ? is the regex wrong? Can anyone help me with the code please?


thanks,
Alex

p.s: another question is: after i get this to work, should I change the links in the php page code to this format? (i told you i am new :P so dont laugh)

EDIT:

the behavior:
1. enter site:
http://localhost/sitename/ <- loads index.php page
2. navigate to: page.php
http://localhost/sitename/page <- displays page.php
3. navitate to: page.php?name=something
http://localhost/sitename/page/something <- STILL displays page.php and looses the css and images folder path (images on the page are no longer dispalyed). the link to an image becomes: http://localhost/sitename/page/images/a.jpg instead of http://localhost/sitename/images/a.jpg as it should.
4. click again to navigate to page.php?name=something
http://localhost/sitename/page/page/something <- each additional click adds a "/page/" to the url

I have no idee why. please help.