Hi, I'm having a hard time with .htacces. I want to create friendly URLs for a site I'm working on...
Basically I want to convert this:
http://website.com/index.php?ctrl=pelicula&id=0221889
http://website.com/index.php?ctrl=pelicula&id=0160399&tab=posters
Into this:
http://website.com/pelicula/0221889/
http://website.com/pelicula/0221889/posters/
In case I need it later I would also want to know how to add the article title to the end of the URL like this (I'm using PHP):
http://website.com/pelicula/0221889/the-article-name/
http://website.com/pelicula/0221889/the-article-name/posters/
Note: Stackoverflow method is also good for me, for example the url of this question is:
http://stackoverflow.com/questions/3033407/htacces-to-create-friendly-urls-help-needed
But you can put anything after the id and it will also work. like this:
http://stackoverflow.com/questions/3033407/just-anything-i-want
I have used some automatic web tools for creating the .htacces file, but its not working correctly. So I ask for your help.
I will also be glad if you can recommend .htacces best practices and recommendations..
EDIT: based on some answers I get here I put this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/([^/]+)/([^/]+)/?([^/]*)/?$ index.php?ctrl=$1&id=$2&tab=$3 [QSA,L]
</IfModule>
But I get the default host 'page not found' error.
I also tried:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/(\d+)/([^/]+)/?$ index.php?ctrl=$1&id=$2&tab=$3 [QSA,L]
RewriteRule ^([^/]+)/(\d+)/?$ index.php?ctrl=$1&id=$2 [QSA,L]
RewriteRule ^([^/]+)/?$ index.php?ctrl=$1 [QSA,L]
</IfModule>
This also does not work. It takes me to my default 404.php page.
mod_rewrite is enabled and working.
Help!