How to Redirect /?amp=1 URLs to Normal URLs on WordPress or Apache
Автор: vlogize
Загружено: 2025-05-26
Просмотров: 12
Описание:
Discover how to easily redirect `/?amp=1` URLs to their normal counterparts using `.htaccess` or a WordPress plugin. Dive into this step-by-step guide!
---
This video is based on the question https://stackoverflow.com/q/69884292/ asked by the user 'MaltaCode' ( https://stackoverflow.com/u/4483283/ ) and on the answer https://stackoverflow.com/a/69884993/ provided by the user 'Amit Verma' ( https://stackoverflow.com/u/3160747/ ) 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: Apache or WordPress plugin that redirects /?amp=1 to normal url
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.
---
Redirecting /?amp=1 URLs to Normal URLs on Apache and WordPress
If you've recently removed AMP (Accelerated Mobile Pages) from your WordPress website, you may have noticed lingering URLs that include /?amp=1. This additional string can be confusing for both users and search engines. Fortunately, there are straightforward methods to effectively redirect these URLs back to their normal versions. In this guide, we will explore how to implement these redirections using either Apache's .htaccess configuration or a WordPress plugin.
Understanding the Problem
When a user visits a URL ending with /?amp=1, they are typically accessing an AMP-optimized version of a page. However, since you've removed AMP support, these URLs can lead to issues such as displaying errors or content that is no longer available. For an optimized user experience and to maintain your site's SEO ranking, it's crucial to redirect these URLs to their proper counterparts.
Solution Overview
We can tackle the redirection problem in two primary ways:
Using Apache's .htaccess File: If your website is hosted on an Apache server, you can easily manage redirects through your site's .htaccess file.
Using a WordPress Plugin: For those who prefer a plugin solution, a variety of WordPress plugins can help manage URL redirections without delving into code.
Option 1: Redirecting with .htaccess
If you have access to your server's .htaccess file, follow these steps to set up the redirect:
Access your .htaccess file: Connect to your website via FTP or use your hosting control panel to locate your .htaccess file, which is typically situated in the root directory of your WordPress installation.
Add Redirection Rules: Place the following code into your .htaccess file. It’s important to do so before any WordPress-specific rules to ensure it executes properly.
[[See Video to Reveal this Text or Code Snippet]]
Here's a breakdown of what this code does:
RewriteEngine On: Activates the rewrite engine for processing URLs.
RewriteCond %{THE_REQUEST} /?amp=1: Checks if the incoming request contains /?amp=1.
RewriteRule ^(.+ )$ /$1? [L,R]: Redirects to the normalized URL without amp, applying a 301 redirect (permanent redirect).
Save Your Changes: After adding the code, ensure you save the file and test the redirection.
Option 2: Redirecting with a WordPress Plugin
For those who are less comfortable with coding, using a plugin is an ideal solution. Here’s how to redirect using a WordPress plugin:
Install a Redirect Plugin: Popular choices include “Redirection” and “Simple 301 Redirects.” You can find these by searching in the Plugins section of your WordPress dashboard.
Configure the Plugin:
Once installed, navigate to the plugin's settings page.
Look for an option to create a new redirect rule.
In the "Source URL," input the variable part of the URL you want to redirect: /?amp=1.
In the "Target URL," include the regular URL (without ?amp=1) that users should be directed to.
Save your changes.
Testing the Redirect
After implementing either solution, it's crucial to test that the redirection works correctly. Simply enter a URL ending with /?amp=1 in your browser and verify that it smoothly redirects to the intended normal URL. This step is essential to ensure a seamless experience for your site visitors.
Conclusion
Redirecting unwanted /?amp=1 URLs back to their normal equivalents is a crucial step to enhance your website's usability and SEO. Whether you prefer the precision of editing the .htaccess file directly or the ease of using a WordPress plugin, these methods will effectively solve your redirect woes. If you follow the outlined steps diligently, you’ll have a cleaner, more user-friendly si
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: