¿Por qué obtengo un 404 para una página sin la barra inclinada final pero funciona con la barra inclinada final?

I have an app that allows users to create and build a site. Let's call it sistema.com. When a user creates a site with a domain (say domain.com) they have forwarded to our nameservers, it creates folders and adds their domain to our server through the cPanel API to a folder like system.com/[user id]/[site id]/. In that folder there's an index.php file and a .htaccess file that reads:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/$ index.php?page=$1 [L]

I won't go into too much detail about how it works from there, but basically the user can create pages like domain.com/something/something-else/. The "something" folders obviously don't really exist and our system just picks them up from the htaccess and goes from there.

Mi problema es que domain.com/something/something-else/ funciona pero domain.com/something/something-else returns a 404. I've been doing research and trying many things but can't seem to get it working. Any ideas? Thanks in advance.

Editar:

I should have mentioned what I've tried so far. I've tried changing the rewriterule to work regardless of the trailing slash, like so:

RewriteRule ^(.*)(?/$) index.php?page=$1 [L]

And other variations of that.

I've also tried different methods of forcing a trailing slash but none of those worked either.

preguntado el 03 de mayo de 12 a las 07:05

Looks like web-server thinks of domain.com/something/something-else como archivo something-else y something-else/ like folder. Try to remove / a partir de su RewriteRule como RewriteRule ^(.*)$ index.php?page=$1 [L] -

so you mean if the user enter a url without a trailing slash the url rewriter must add a trailing slash automatically? -

Hmm, nope that didn't work either. -

then what is you are trying to do? -

@Mahan well ideally it should pull up the correct page regardless of trailing slash or not, but that's fine if it also does an initial redirect that adds a trailing slash. I just don't understand why nothing works -- even a standard 301 like RewriteRule ^something/something-else$ /something/something-else/ [R=301] -

2 Respuestas

I think you want your rule to look like this:

RewriteRule ^(.*)/?$ index.php?page=$1 [L]

Which says : "Any number of any characters optionally followed by a slash should be changed to index.php?page=$1 where $1 is the characters you found before the slash. Also disregard any other rules that you find if this one matches."

respondido 18 nov., 12:22

its based on your url rewrite access rule..

RewriteRule ^(.*)/$ index.php?page=$1 [L]

como puedes ver index.php?page=$1 is aliased into / and all the requests is sent to index.php

contestado el 03 de mayo de 12 a las 07:05

Right, well that's the behavior that we want and everything works fine when you have a trailing slash. I added an edit to my original post to show some of the fixes I've tried - phx_zs

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.