mod rewrite para redirigir todo excepto la raíz

so I have and if someone lands on I want them to see the funny picture but if they goto I need it to redirect with a 301 to

        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$$1 [R=301,L,QSA]

But this doesn't redirect to anything. But I have verified that other redirect rules can work.

preguntado el 04 de julio de 12 a las 01:07

Define "do anything". Does RewriteRule ^(.*)$$1 [R=301,L] do "anything"? If not you need to configure your server to read these instructions properly. -

Yes that redirects all traffic. When I say does nothing I mean never redirects them but displays the site as one would normally except, with a 404 error. -

1 Respuestas

Try using a rewrite condition that inverts a match on / for the specific domain.

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{HTTP_HOST} ^(www\.)?somefunnywebsite\.com$ [NC]
RewriteRule ^.*${REQUEST_URI} [R=301,L,QSA]

I haven't tested it but that should get you started. (I'd suggest using a 302 to start as browsers tend to cache 301 redirects.)

Respondido 04 Jul 12, 03:07

Still just giving a 404 on - El Ninja Digital

changing the ReqriteRule to RewriteRule ^(.*){REQUEST_URI} [R=302,L,QSA] seems to have worked. Thanks. - El Ninja Digital

Edited my answer. Using a grouping doesnt matter, as %{REQUEST_URI} wouldn't be affected by it. Use a grouping like that if you redirect to$1 [R=301,L,QSA] para que funcione. - jmkeyes

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