• Resolved dlsn

    (@dlsn)


    Hallo zusammen,

    ich würde gerne in meiner .htacces einen Redirect einrichten.

    Von

    https://www.domain.de/t/

    Nach

    https://www.domain.de/neuesVerzeichnis

    Aber:

    https://www.domain.de/t/unterverzeichnis

    soll nicht umgeleitet werden.

    Wenn ich das folgende mache, werden auch alle Unterverzeichnisse umgeleitet:

    Redirect 301 /t/ https://www.domain.de/neuesVerzeichnis

    Wie kann ich das umsetzen, dass nur die eine URL

    https://www.domain.de/t/

    und nicht die anderen

    https://www.domain.de/t/unterverzeichnis

    umgeleitet werden?

    Vielen Dank
    Gru? Daniel

    ** ENGLISH **

    Hello there,
    I would like to set up a redirect 301.

    From
    https://www.domain.de/t/

    To
    https://www.domain.de/u

    But:
    https://www.domain.de/t/name

    shouldn’t be redirected.

    If I try it like the following every URL with /t/… is redirected:
    Redirect 301 /t/ https://www.domain.de/u

    How can I solve it that only the url https://www.domain.de/t/ and not the other urls like https://www.domain.de/t/name are redirected?

    Thank you!
    Daniel

    • This topic was modified 3 years, 5 months ago by dlsn.
    • This topic was modified 3 years, 5 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    The Redirect directive is too simplistic for your needs. RedirectMatch lets you use regexp to build more complex criteria. Regexp is not my strength. There may be a solution there, but I’m unsure how to accomplish it.

    You can use a RewriteRule set to build very complex criteria. The following is untested and may contain syntax errors, but hopefully it’ll point you in the right direction.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^t/
    RewriteCond %{REQUEST_URI} !^t/unterverzeichnis/
    RewriteRule ^t/(.*) /neuesVerzeichnis/$1 [L]
    </IfModule>
    Thread Starter dlsn

    (@dlsn)

    @bcworkz thank you for your help.

    I just found a possibility to solve my problem:

    RewriteCond %{REQUEST_URI} ^/t/?$
    RewriteRule (.*) /neuesVerzeichnis [R=301,L]
    Moderator bcworkz

    (@bcworkz)

    If that works for you then great! There’s never additional URL content like /t/foo/ where you’d want it to go to /neuesVerzeichnis/foo/? If that’s not needed, then my suggestion is overly complex.

    Assuming /neuesVerzeichnis is a WP URL, you may as well rewrite to /neuesVerzeichnis/ (added terminal slash) otherwise WP will do a second redirect to add it.

    Thread Starter dlsn

    (@dlsn)

    @bcworkz Yes, it works.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Redirects from a single page’ is closed to new replies.