Friday, 15 January 2010

From trailing slash to query (PHP/.htaccess) -



From trailing slash to query (PHP/.htaccess) -

i maintain links in address bar short , clean possible, example:

http://example.com/th1ng

if in database there row 'th1ng' username, above link should work like

http://example.com/user.php?name=th1ng

while still showing first, clean link in address bar.

if user doesn't exist, shows/redirects 404 page.

also, there other files , directories need access via trailing slash too. , possible there query on top well, like

http://example.com/th1ng?img=13805

which should deed like

http://example.com/user.php?name=th1ng?img=13805

i got of php stuff, including database check , redirecting 404 in case user doesn't exist.

but.. proper way around showing clean link in address bar? other files , directories on server still beingness accessible well. can assume .htaccess needs used don't see how exactly.

thanks help!

you need utilize mod_rewrite that. placed in .htaccess.

rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ user.php?name=$1 [qsa,l]

php .htaccess slash

No comments:

Post a Comment