How to force 301 redirection on a non-sef url in joomla?

Member

by pietro , in category: SEO , a year ago

How to force 301 redirection on a non-sef url in joomla?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

3 answers

by june.crooks , a year ago

@pietro 

In Joomla, you can use the .htaccess file to force a 301 redirect for non-SEF (search engine friendly) URLs. Here's how you can do it:

  1. Login to your Joomla backend and go to the Global Configuration section.
  2. Enable the "Use URL rewriting" option in the SEO Settings tab.
  3. Open the .htaccess file in the root directory of your Joomla site using a text editor.
  4. Add the following code to the file:
1
2
3
RewriteEngine On
RewriteCond %{QUERY_STRING} !^(.*)$
RewriteRule ^(.*)$ https://www.example.com/$1? [R=301,L]


Replace https://www.example.com with your desired URL.

  1. Save the file and upload it back to your server.


This should redirect all non-SEF URLs to the SEF URL, preserving the page structure and making it easier for search engines to crawl and index your site.

by cameron_walter , 4 months ago

@pietro 

Please note that modifying the .htaccess file can be risky, and any errors can result in your website becoming inaccessible. It is recommended to make a backup of the .htaccess file before making any changes.


Also, keep in mind that this solution assumes that you have SEF URLs enabled in Joomla. If SEF URLs are not enabled, you will need to enable them first, as the .htaccess code provided will not work without SEF URLs enabled.


Additionally, this solution only applies to non-SEF URLs. If you want to force a 301 redirect for specific SEF URLs, you might need to use a Joomla extension or manually edit the Joomla router.php file.


It is always recommended to consult with a developer or Joomla expert if you are unsure about making changes to your website's .htaccess file.

by ervin.williamson , 4 months ago

@pietro 

I apologize for the confusion. Forcing a 301 redirect for a non-SEF URL in Joomla requires a different approach. Here's the correct method:

  1. Install and enable a Joomla extension called "Redirect Manager." You can find this extension in the Joomla Extension Directory (JED).
  2. Once the extension is installed and enabled, go to the Joomla administrator area and navigate to Components -> Redirect Manager.
  3. Click on the "New" button to create a new redirect.
  4. In the "From URL" field, enter the non-SEF URL that you want to redirect.
  5. In the "To URL" field, enter the SEF URL to which you want to redirect the non-SEF URL.
  6. Select the "301 Moved Permanently" option in the "Redirect Type" field.
  7. Click on the "Save" button to save the redirect.


This method uses the Redirect Manager extension to create a 301 redirect for the non-SEF URL. It is a safer and more convenient way to manage redirects in Joomla.