How to Search and Replace Old URLs in Joomla
When migrating a Joomla website to a new domain or making structural changes to your content, you may encounter outdated internal links or image paths. Updating these manually can be time-consuming and prone to errors - especially on large websites. Fortunately, there are effective ways to search and replace old URLs in Joomla quickly and safely.
IMPORTANT: Before You Begin Make a Backup.
Before performing any changes, always create a full backup of your Joomla site. You can use extensions like Akeeba Backup to safely restore your site in case something goes wrong.
Use a Joomla Database Tool (phpMyAdmin)
You can perform a search and replace directly in the database using phpMyAdmin, which is available in most hosting control panels (like cPanel or Plesk).
Log in to phpMyAdmin via your hosting control panel.
Select your Joomla database.
Click on the SQL tab.
Run a query like this:
sql: UPDATE 'your_table'
SET 'your_column' = REPLACE('your_column', 'http://oldurl.com', 'https://newurl.com');
Example for articles:
sql: UPDATE '#__content'
SET 'introtext' = REPLACE('introtext', 'http://oldurl.com', 'https://newurl.com'),
'fulltext' = REPLACE('fulltext', 'http://oldurl.com', 'https://newurl.com');
Replace '#__content' with your actual table prefix (e.g., 'jos_content' or 'abc_content').
Direct SQL changes are powerful but risky. Double-check your queries.
Use a Joomla Extension
If you prefer a safer, user-friendly approach, use a Joomla extension designed for search and replace.
DB Replacer (by Regular Labs)
Allows you to search and replace within any database table from the Joomla admin panel.
Supports partial or full-text search and offers a preview of affected rows.
- Install DB Replacer from the Joomla Extensions Directory.
- Go to Components → DB Replacer.
- Select the table (e.g., 'content') and the columns to search in.
- Enter the old and new URLs.
- Click Replace.
Use Joomla Content Editor (JCE) Tools
If you're using the popular JCE Editor, it includes tools to edit URLs in articles more easily:
Open each article using the editor.
Use the HTML "Source" or "Link Inspector" tool to update individual links.
This is not ideal for large-scale updates, but helpful for spot-checking.
IMPORTANT: Don't Forget to Clear Joomla Cache.
After replacing URLs, clear your cache to make sure changes appear on the frontend:
- Go to System → Clear Cache.
- Select all items and click Delete.
Also, you can clear your browser cache.
Use ".htaccess"
The primary tool for this is the RewriteRule directive, part of Apache's mod_rewrite module.
- Access to your .htaccess file: It's usually in the root directory of your website (e.g., public_html/, htdocs/, or /www/).
- mod_rewrite enabled: It almost always is on standard hosting plans.
- Use basic text editor: Like Notepad++ or VS Code. Avoid rich-text editors like Word.
First, you need to activate the rewrite engine. Your .htaccess file should typically start with these lines: RewriteEngine On.
1. Enable Rewrite Engine: RewriteEngine On.
2. Set the Base Directory: RewriteBase.
3. Rewrite URLs.
RewriteRule ^old_url/(.*)$ new_url/$1 [NE,R=301,L,NC]
RewriteRule ^old_url2/(.*)$ new_url2/$1 [NE,R=301,L,NC]
These are redirect rules that take visitors from an old URL path and send them to a new one.
RewriteRule: This directive defines a rule for how incoming requests should be rewritten (or redirected).
- ^old_url/(.*)$: This is a regular expression that matches the requested URL.
- '^' → means "start of the URL path".
- 'old_url/' → matches the literal folder or path 'old_url/'.
- '(.*)' → captures everything after 'old_url/' (zero or more characters).
- '$' → means "end of the URL path"
Example: 'https://example.com/old_url/page1' → matches, and 'page1' is captured by '(.*)'.
'new_url/$1': This is the target (redirected) URL.
- 'new_url/' → the new base path.
- '$1' → inserts whatever was captured by '(.*)'.
Example: old_url/page1' → becomes 'new_url/page1'; 'old_url/some/sub/page' → becomes 'new_url/some/sub/page'
Flags: '[NE,R=301,L,NC]': These are special instructions for the rewrite.
'NE' = No Escape: Prevents Apache from escaping special characters in the output URL.
Example: '%20' stays as a space instead of being converted.
- 'R=301' = Redirect with HTTP 301 status. Sends a 301 Moved Permanently redirect (good for SEO). Tells search engines and browsers: *“This page has moved permanently.”
- 'L' = Last rule. If this rule matches, stop processing any further rewrite rules.
- 'NC' = No Case: Makes the match case-insensitive.
- 'old_url/' = 'OLD_URL/' = 'Old_Url/'.
Rule 1:
Any request starting with '/old_url/...' → gets redirected to '/new_url/...'.
Rule 2:
Any request starting with '/old_url2/...' → gets redirected to '/new_url2/...'.
'https://example.com/old_url/about' → 'https://example.com/new_url/about'
'https://example.com/old_url2/products/item1' → 'https://example.com/new_url2/products/item1'
These rules are set up to permanently redirect old URLs to new ones (with all subpages preserved), using a 301 redirect for SEO, in a case-insensitive way.
Replacing old URLs in Joomla doesn't have to be complicated. Whether you're a beginner using an extension like DB Replacer or a developer working directly with the database, there are safe and efficient ways to keep your site's links clean and accurate. Always back up first, test your changes, and clear your cache and your Joomla site will be cleaner, faster, and more SEO-friendly.


