views:

29

answers:

1

I just wanted that when this is inserted in the URL:

http://website.com/pelicula/0221889/
http://website.com/pelicula/0221889/posters/

It really goes to this (in background):

http://website.com/index.php?ctrl=pelicula&id=0160399
http://website.com/index.php?ctrl=pelicula&id=0160399&tab=posters

So I put this in my .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^/([^/]+)/([^/]+)/?([^/]*)/?$ index.php?ctrl=$1&id=$2&tab=$3 [QSA,L]
</IfModule>

But it was not working in my web host so I asked for help from their support team and this was their response:

<IfModule mod_rewrite.c>
RewriteEngine On
# If subdomain www exists, remove it first
#RewriteCond %{HTTP_HOST} ^www.([^.]+.[^.]+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# If requested resource does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# and does not end with a period followed by a filetype
RewriteCond %{REQUEST_URI} !..+$
# and does not end with a slash
RewriteCond %{REQUEST_URI} !/$
# then add a trailing slash and redirect
RewriteRule (.*) $1/ [R=301,L]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Obviously its not working as desired so I just want to know how to fix this!!! I don't know nothing about mod_rewrite and I really need this to work perfectly... I'm going mad I don't know where is the problem.. please help!

+1  A: 

It seems that the support guys just sent you the first URL-rewriting code they found in their knowledge base to serve as sample. And it's normal: no hosting service in the world can provide free consulting services :)

I suggest you try to keep it simple:

<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>
Álvaro G. Vicario
Yes, but this is very similar to the code that was not working in first place...
Jonathan
And by the way its not working...
Jonathan
It does work for me. In what way doesn't it work for you? Do you have other rules that may be interfering? Do you have mod_rewrite available?
Álvaro G. Vicario
Yes, mod_rewrite is enabled. If I insert website.com/home it takes me to index.php?ctrl=home but if a put a slash at the end it does't works, also website.com/pelicula/0221889/ is not working, I get: Page not found. The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
Jonathan
Thanks for the feedback. But, seriously, it works for me as is, trailing slash or not (that's what `/?$` controls). There's something else interfering and I can't figure out what :(
Álvaro G. Vicario