Hello All:

I´ve recently switched my site from normal html to Joomla1.5, and I need to do some 301 Redirects. I´m not sure if what I want to do is possible, but I figured I would ask.

Goal 1. I want to redirect ALL .htm files to www.mydomain.com EXCEPT for those contained in a subfolder,
Goal 2. However, I want to exclude a couple of specific .htm files, which would be redirected to specific pages and not to www.mydomain.com. Right now I have 301 redirects written for these, but I didn´t know if goal #1 would take precidence over these or not.

Option #2: Another option, if anyone knows how to do it, would be to redirect all files in mydomain.com that start with a certain letter to one file ... for example, all files in www.mydomain.com that start with E would be redirected to www.mydomain.com/newpageE.html

Any help you could give me would be greatly appreciated!
Thank you!

Dani AI

Generated

For (Joomla 1.5 migration): server-level 301s in the root .htaccess are the cleaner, SEO-friendly solution — they are faster and more reliable than PHP/meta-refresh approaches mentioned by . The two critical rules are ordering (place specific redirects before any wildcard) and exclusion (make sure the /archives/ folder is exempt). Custom redirects must go above Joomla's SEF rewrite block so they run first.

RewriteEngine On

# specific file redirects (place these FIRST)
RewriteRule ^oldpage1\.htm$ /newpage1.html [R=301,L]
RewriteRule ^oldpage2\.htm$ /newpage2.html [R=301,L]

# exclude /archives/ then redirect any .htm to site root
RewriteCond %{REQUEST_URI} !^/archives/ [NC]
RewriteRule \.htm$ / [R=301,L]

Alternative (Option #2) — redirect any .htm that begins with the letter "E" to a single page:

# redirect any .htm starting with "E" (case-insensitive) to /newpageE.html
RewriteRule ^e[^/]*\.htm$ /newpageE.html [R=301,L,NC]

Notes and cautions: place explicit redirects before the catch-all so they take precedence; test rules as temporary 302s before committing 301s (browsers cache 301 aggressively); clear browser cache and verify responses with curl -I or an HTTP header checker. To drop query strings use the QSD flag on Apache 2.4+ ([R=301,L,QSD]) or append a literal ? to the target on older servers (e.g., /newpage.html?). Back up the existing .htaccess, ensure mod_rewrite is enabled, and keep these lines above Joomla's SEF rules so core routing is not overridden.

You can do redirection of your web pages from within the control of your web hosting account. I know cPanel has such function.

But if you don't want to go that route, this is a simple PHP code for URL redirection:

<?php
   ob_start();
   echo "Redirecting......";
   echo '<meta http-equiv="refresh" content="0;url=http://www.mydomain.com/" />';
   ob_flush();
?>

Copy and paste this code on every web page you'd like redirected to www.mydomain.com

For the other part, you have to change "url=http://www.mydomain.com/" to "url=www.mydomain.com/newpageE.html"

I hope this will help a bit.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.