У нас вы можете посмотреть бесплатно Crafting 301 Redirects for Multilingual URLs with .htaccess или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
Learn how to create effective `301 redirects` in your .htaccess file to manage multilingual URLs on your website. --- This video is based on the question https://stackoverflow.com/q/74432462/ asked by the user 'Ville Teronen' ( https://stackoverflow.com/u/20500693/ ) and on the answer https://stackoverflow.com/a/74434388/ provided by the user 'Valeriu Ciuca' ( https://stackoverflow.com/u/4527645/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions. Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: Adding directory to url with htaccess & rewrite Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l... The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license. If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com. --- Crafting 301 Redirects for Multilingual URLs with .htaccess Managing multiple languages on a website can often come with its own set of challenges — especially when it comes to URLs. If you are working with Modx CMS and have recently implemented multilingual functionality, you might find yourself needing to redirect old links to their new, language-specific counterparts. In this guide, we will explore how to effectively use .htaccess rules to achieve this goal and avoid common pitfalls, such as redirect loops. The Problem: Redirecting to Language-Specific URLs When implementing multilingual capabilities, it’s essential to redirect users and search engines correctly. In our scenario, we want to ensure that: Default URL: Requests for example.com/products should redirect to example.com/en/products. Language-Specific URL: If a URL already contains a language code (like /de), it should remain unchanged, avoiding issues like example.com/en/de/products. Avoiding Redirect Loops: Ensure that the redirection doesn’t lead to an infinite loop where /en gets added multiple times. The initial approach resulted in a redirect loop. Let's examine how to create an effective and correct redirection setup. The Solution: Updating Your .htaccess File To resolve the issues with URL redirection in your setup, you can adopt the following rules in your .htaccess file. The revised rules will ensure that the /en/ prefix is only added when it’s not already present in the URL. Step-by-Step Code Explanation Here's the suggested code you can place in your .htaccess file: [[See Video to Reveal this Text or Code Snippet]] Breaking Down the Code Enable Rewrite Engine: The first line, RewriteEngine On, turns on the rewrite engine, allowing the rules that follow to take effect. HTTPS Redirect: The rules check if the connection is not secure and redirect it to HTTPS to ensure better security and SEO. Conditional Checks for Language Redirection: RewriteCond %{REQUEST_URI} !^/en: Checks if the request URI does not start with /en. RewriteCond %{REQUEST_URI} !^/de: Checks if it does not start with /de. RewriteCond %{REQUEST_URI} !^/$: Ensures the root URL is excluded. RewriteCond %{REQUEST_FILENAME} !-f: Confirms the requested filename does not exist as a file. RewriteCond %{REQUEST_FILENAME} !-d: Confirms the requested filename does not exist as a directory. Performing the Redirect: If all conditions are met, the rule redirects the request to the version with /en added to the URL. Routing Requests: Finally, requests for URLs that do not exist as files or directories are routed through index.php, allowing Modx CMS to handle them appropriately. Conclusion With the provided .htaccess configuration, you can effectively manage multilingual URLs on your Modx CMS site without falling into redirect loops. By incorporating these 301 redirects, you'll not only enhance the user experience but also improve your site's SEO compatibility. Redirecting users to the correct language version ensures that all potential visitors can easily navigate the content in the language they prefer. Recap: Always ensure your conditions are accurate to prevent access issues, and regularly test the setup to maintain website integrity. Happy coding!