tags:

views:

92

answers:

1

I'm writing my own url shortener. I'm done with everything such as creating short urls. But when I try to browse htt p://example.com/rtr93, I get a 404 error. But http://example.com/index.php/rtr93 works find and shows the relevant page (I'm not redirecting to a new url. I'm just getting the relevant record from database which has a column short_url).

I'm using PHP and syfmony 1.2 if that helps. I think I need to properly setup .htaccess file. But I don't know where to get started.

+1  A: 

Something like this should work:

RewriteEngine on
RewriteBase /

RewriteRule ^(.*)$ /index.php [L]

You may want to make the regex more specific if you're planning on hosting other things on the same domain.

Laurence Gonsalves
no. I still get 404 error page. I think apache is trying to look for http://example.com/rtr93 page and throwing 404 error
Apache shouldn't do the error handling until after the rewrites have been processed, and by that time the request is for /index.php. Perhaps your .htaccess has the wrong permissions? Try "chmod 644 .htaccess". Also, some web hosts take a few minutes to respond to .htaccess changes.
Laurence Gonsalves
@Laurence - Some hosts dont allow .htaccess to be modified, and others don't have the mod_rewrite enabled ...
phalacee