myPage .htaccess SEO rules
.htaccess is an Apache configuration file that controls directory-level behavior
without editing the main server config. For SEO it is one of the strongest server-side tools:
permanent and temporary redirects, HTTPS and www (or non-www) enforcement, trailing-slash consistency,
clean URLs, parameter cleanup, and deliberate content removal (410 Gone).
Small mistakes can create redirect loops or dilute rankings.
Always test after upload. Align canonical tags, sitemaps, and internal links with the URLs these rules enforce.
See also: myPage overview | tools reference | meta tags | error pages
Modern channel only: Tools → .htaccess Rules… (toolbar .ht) builds and writes
a project-root .htaccess file. Apache hosts honor it; Nginx, IIS, and many static hosts ignore it.
The file is included in Download Site (ZIP) and can be opened in Code view.
Using the .htaccess Rules tool
- Open your site in modern myPage.
- Optionally set Contact Meta Tags → Site URL (og:url) so the tool can suggest HTTPS and www preference.
- Choose Tools → .htaccess Rules… or the .ht toolbar button.
- Enable the rules you need; add 301/302 rows and 410 paths as required.
- Review the live preview, then click Apply .htaccess.
- Download the site ZIP and upload
.htaccess to the site root on an Apache host.
- Test HTTP vs HTTPS, www vs non-www, old page URLs, and a 410 path before going live.
Re-opening the tool reloads options from the myPage-config comment inside the generated block.
Anything you put in Custom rules is kept below the managed block when you re-apply.
Why .htaccess matters for SEO
- Redirect management: 301 redirects preserve nearly all link equity when URLs move.
- Canonical domains: one www or non-www version, plus HTTPS, prevents duplicate indexing.
- Crawl efficiency: clean URLs and parameter cleanup reduce wasted crawl budget.
- Error handling: proper 404 and 410 responses tell crawlers what to do with missing content.
Without smart configuration you risk duplicate content, broken links after migrations, slow pages, and wasted crawl budget.
301 permanent redirects
A 301 means a page has moved permanently. Browsers, users, and search engines should use the new URL.
301s have existed since HTTP/1.0 (RFC 1945, 1996). Modern engines pass the vast majority of link equity
(often cited around 90% to 99%) from the old URL to the new one.
Why they matter:
- Preserve link authority from old backlinks
- Consolidate ranking signals when content moves
- Prevent old and new URLs from competing as duplicates
- Avoid 404s for users and crawlers during rebrands and migrations
Syntax (also generated by the tool from the 301 table):
Redirect 301 /old-page.html https://www.example.com/new-page/
- Use an absolute destination URL
- Redirect directly to the final URL (no 301 chains)
- Point to the most relevant replacement page, not always the homepage
- Prefer 301 over outdated
<meta http-equiv="refresh"> redirects
302 temporary redirects
A 302 means a temporary move. The original URL should remain indexed and keep its ranking.
Use 302 for seasonal promos, short maintenance, geolocation experiments, or A/B tests.
If the move becomes permanent, change it to a 301 and remove expired 302s.
Redirect 302 /products/widget/ https://www.example.com/products/widget-promo/
Misusing a 302 for a permanent move can leave authority split and rankings weak.
Do not stack temporary redirects into chains.
Canonical domain redirects (www vs non-www)
Search engines historically treated www.example.com and example.com as separate sites.
Leaving both live splits link equity and wastes crawl budget. Pick one brand preference and 301 everything else to it.
SEO-wise either style can rank; consistency is what matters.
Force non-www + HTTPS (tool option: Enforce HTTPS + Force non-www):
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
Force www + HTTPS:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,R=301]
- Use 301, not 302, for domain canonicalization
- Match
<link rel="canonical">, sitemap <loc>, and Contact Meta og:url to the same host
- Test carefully to avoid redirect loops
HTTPS enforcement
Google made HTTPS a ranking signal in 2014. By 2018 major browsers labeled plain HTTP pages as Not Secure.
Google, Bing, DuckDuckGo, Snipesearch.net, and other engines expect HTTPS by default.
Serving both HTTP and HTTPS without redirects creates duplicate content.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
- Always use 301 for HTTPS enforcement
- Update internal links to HTTPS where practical
- Avoid mixed content (HTTP images/scripts on HTTPS pages)
Trailing slash redirects
/page and /page/ can be indexed as two URLs. Choose one style and redirect the other.
Directory-style CMS URLs often keep the slash; flat file sites often omit it. Either is fine if consistent.
Remove trailing slash (skip real directories):
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]
Add trailing slash (skip real files):
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ /$1/ [R=301,L]
Canonical tags must use the same slash style as the redirect destination and the sitemap.
URL parameter cleanup
Tracking parameters (utm_*, gclid, fbclid, ref, session IDs) create near-duplicate URLs.
Left unchecked they inflate the index, dilute links, and waste crawl budget.
Strip tracking params with a 301 to the clean path when they do not change visible content.
Keep real filters, product IDs, and meaningful pagination.
The tool option Strip tracking params generates a rule that removes common campaign and session query keys.
Strip all query strings is aggressive: only use it on pages where no parameter should ever appear.
Always pair redirects with matching canonical tags.
410 Gone (permanent content removal)
410 means the resource was intentionally removed and is not coming back.
It is a stronger deindexing signal than 404. Defined in HTTP/1.1 (RFC 2616, 1999).
| Use 410 | Use 404 |
| Content retired forever | Temporary miss or typo |
| Legal or privacy takedown | Page might return |
| Pruning thin / expired content | Out of stock but may restock (or use 301 to replacement) |
Redirect gone /old-content/no-longer-available.html
Google, Bing, Snipesearch.net, DuckDuckGo, and YaCy/Sphider-style engines treat 410 as an explicit removal request.
410 does not pass link equity. If a replacement exists, use a 301 instead.
Remove 410 URLs from your XML sitemap.
Clean URLs and hiding extensions
Clean (pretty) URLs omit cryptic IDs and often omit .html / .php.
Apache mod_rewrite can map /about to about.html internally,
and 301 redirect old extension URLs to the clean form so only one version is indexed.
Hide .html (internal rewrite):
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]
Redirect .html to extensionless (301):
RewriteCond %{THE_REQUEST} \s/+(.+)\.html[\s?] [NC]
RewriteRule ^ /%1 [R=301,L]
- Use lowercase and hyphens in public URLs
- Do not rewrite CSS, JS, or image paths
- Match canonical tags and sitemaps to the clean URL
- Update internal links to avoid unnecessary redirect hops
Pseudo directories (keyword-optimized paths)
Pseudo directories are virtual URL folders that look hierarchical even when the site uses flat files or scripts.
Example public URL: https://example.com/products/shoes/red-sneakers
which may internally serve product.php?category=shoes&name=red-sneakers.
No physical /products/ folder is required. Google, Bing, Snipesearch.net, DuckDuckGo,
Sphider, and YaCy all benefit from descriptive path segments over bare query strings.
Why they matter:
- Keyword clarity in each path segment
- Clearer crawl hierarchy and content relationships
- Better click-through and sharing than
?id= URLs
- No filesystem bloat from real empty folders
In myPage open Tools → .htaccess Rules, section Pseudo directories.
Set a path prefix, comma-separated query param names (in path order), and the target script.
Use Insert products example for a ready-made products / category,name / product.php mapping.
Check 301 old to redirect legacy query URLs to the clean path.
Internal rewrite (clean path to script):
RewriteEngine On
RewriteRule ^products/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ product.php?category=$1&name=$2 [L,QSA]
301 old parameter URL to the clean version:
RewriteCond %{THE_REQUEST} \?category=([^&]+)&name=([^&\s]+)
RewriteRule ^product\.php$ /products/%1/%2? [R=301,L]
Request /product.php?category=books&name=dark-fiction becomes
/products/books/dark-fiction. Link equity consolidates on the clean URL.
Best practices:
- Hyphens for multi-word slugs (
red-sneakers, not red_sneakers)
- Lowercase only
- Match your category and tag taxonomy
- Canonical and sitemap URLs must use the pseudo path, not the query form
- Avoid trailing slashes on these paths unless you enforce them site-wide
- If you map a PHP script here, prefer the pseudo 301 over the blanket "redirect .php to extensionless" option
Canonical and sitemap must match:
<link rel="canonical" href="https://example.com/products/fitness/yoga-mat" />
<loc>https://example.com/products/fitness/yoga-mat</loc>
Forcing lowercase URLs
Apache treats /Page and /page as different resources.
Mixed case can duplicate content and split authority.
The myPage tool can emit per-letter 301 rules that work inside .htaccess
(Apache RewriteMap cannot be used from .htaccess; it requires main server config).
Optional cache headers
The tool can enable mod_expires far-future caching for CSS, JavaScript, and images.
That improves load time and crawl efficiency for static assets. HTML pages stay uncached by this block.
Common mistakes
- Redirect chains (A to B to C) instead of A straight to C
- Using 302 for permanent HTTPS or domain changes
- Redirect loops from conflicting www and HTTPS rules
- Canonical tags or sitemaps that disagree with redirect destinations
- Stripping query parameters that change page content
- Serving 410 for pages that still have a useful replacement (use 301)
- Leaving both extension and extensionless URLs live without a 301
- Mixing query URLs and pseudo paths without a 301 and matching canonicals
Recommended SEO workflow with myPage
- Set site-wide and per-page meta (Technical, Contact, Social, SEO Inspector), including self-canonical URLs
- Generate sitemap.xml and robots.txt
- Configure .htaccess Rules for HTTPS, preferred host, redirects, pseudo directories, and cleanup
- Generate Error Pages and point ErrorDocument at 404/410/500/503 (see error pages guide)
- Ensure canonical tags, sitemap URLs, and .htaccess destinations all match
- Check Links, download ZIP, upload to Apache, then verify redirects in a browser and Search Console
Legacy channel: Legacy myPage can keep and edit an existing .htaccess file in the project ZIP,
but the guided .htaccess Rules manager is available in the
Modern Start Center myPage only.
|