0

I have three URLs for every entry:

1 https://www.xy.de/site/single/zahnraeder-zeichnen-aufgaben

2 https://www.xy.de/site/single/zahnraeder-zeichnen-aufgaben/3093

3 https://www.xy.de/site/single/3093

Is there any way to redirect them to 1 ? I would prefer to kill 2 and 3 permanently, but I don't know how to do this technically.

Thanks for any advice!

2 Answers 2

0

you'll want to use 301 redirects in your .htaccess file

e.g:

Redirect 301 /site/single/zahnraeder-zeichnen-aufgaben/3093 /site/single/zahnraeder-zeichnen-aufgaben
Redirect 301 /site/single/3093 /site/single/zahnraeder-zeichnen-aufgaben

(pay attention to the spaces)

and something like this should be at the top of your .htaccess file:

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC] 
RewriteRule ^ https://www.xy.de%{REQUEST_URI} [R=301,L,NE]
1
  • Thanks, but I would have to do this for every single entry. I have a lot of entries which all have to be directed, so I need a dynamic solution.
    – BNetz
    Commented Feb 6 at 17:16
0

Are all of those entries using the same template?

If so I would setup a template route in the CP. Something like:

/site/single/{title:alpha_dash}

And in your template route make sure you require segments.

In your template I would use url_title="{segment_3}" in your exp:channel:entries loop and add:

{if no_results}
    {redirect="404"}
{/if}

Additionally, consider adding the following to your template (in your entries loop) if the above doesn't cover it.

{if segment_4}
    {redirect="/site/single/{url_title}"}
{/if}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.