By Greg Nowak. Last updated 2026-09-13.
When /, /index.html, and /index.php serve the same page, your website gives visitors several addresses for one destination. That can split page-level reporting and leave agencies maintaining inconsistent links across campaigns, navigation, and sitemaps.
The usual fix is a permanent redirect to the clean URL, combining filename removal with your preferred hostname and HTTPS. For a business owner or operations lead, the acceptance criteria are straightforward: visitors reach the correct page, campaign parameters survive, and enquiries still work. Here is how to give your developer a clear brief and check the result.
Confirm that the URLs really are equivalent
Before removing a filename, compare the content and behaviour at both addresses. If index.html is an old landing page while index.php runs the current application, they need a deliberate content decision. A matching filename alone does not establish equivalence.
Choose the preferred hostname and map each affected URL to its destination. Normally, /services/index.php becomes /services/, preserving its directory. Sending every index page to the homepage would lose the visitor’s intended destination.
Google recommends permanent server-side redirects for permanent URL changes and uses them as a canonicalization signal. This gives search engines a clear preference; it does not promise a ranking increase. Google’s redirect guidance explains the distinction between permanent and temporary moves.
Choose where the redirect belongs
| Your setup | Implementation choice | Check before rollout |
|---|---|---|
| Shared hosting | Document-root .htaccess | Hosting permissions and existing CMS rules |
| Apache server you control | Main server configuration | Correct virtual hosts and rule context |
| CDN or reverse proxy | Coordinate redirects with the layer handling public HTTPS | Protocol detection and competing redirects |
| Migration or mixed legacy content | Explicit URL mapping before general cleanup | Each destination preserves the intended content |
Apache recommends using the main configuration when you have access. On shared hosting, confirm that mod_rewrite is enabled and the host permits rewrite directives through AllowOverride FileInfo or an appropriate AllowOverrideList. See Apache’s .htaccess guidance.
A document-root .htaccess example
This Apache 2.4 example combines filename, hostname, and HTTPS redirects. It assumes Apache handles the public TLS connection, ordinary URL paths, and equivalent directory pages. Replace example.com with your canonical domain. Place these rules before CMS routing rules, outside any block the CMS regenerates.
RewriteEngine On
# Explicit index request: go directly to the final URL
RewriteCond %{THE_REQUEST} "\s/+(?:[^?\s]*/)?index\.(?:html|php)[?\s]"
RewriteRule ^(.*/)?index\.(?:html|php)$ https://example.com/$1 [R=301,END]
# Other requests: normalize hostname and protocol
RewriteCond %{HTTP_HOST} !^example\.com$ [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,END]A request for http://www.example.com/services/index.php should go directly to https://example.com/services/. The fixed hostname keeps the destination under your control. These patterns are for the document-root .htaccess; moving them into a virtual host or subdirectory requires adjustment.
The filename match is intentionally lowercase. Review uppercase variants, encoded characters, and paths such as /index.php/products separately. If forms or integrations submit directly to an index URL, agree their routing before applying permanent redirects: a 301 can cause clients to change POST requests into GET requests.
Keep internal routing and query strings working
THE_REQUEST checks the original client request, distinguishing an explicit index filename from a CMS internally routing a clean URL through index.php. That distinction prevents this cleanup rule from redirecting ordinary front-controller requests. Apache documents the variable in its mod_rewrite reference.
Because neither destination supplies a query string, Apache retains the existing one. For example, /services/index.php?utm_source=newsletter becomes /services/?utm_source=newsletter. There is no need to add QSA here. The QSD flag discards the entire query string; use it only when that is intentional. See Apache’s rewrite flags documentation.
Also check DirectoryIndex: the clean directory URL must serve the intended page. Leave DirectoryIndexRedirect off for this approach; enabling it sends visitors back to the index resource and can create a loop. Keep normal directory slash handling unless the application explicitly requires otherwise. These behaviours are covered in Apache’s mod_dir documentation.
Check proxies and existing redirects
If a proxy terminates HTTPS, Apache may see HTTP even when the visitor used HTTPS. The example’s HTTPS condition then needs an infrastructure-specific replacement. Use forwarded protocol information only from a trusted proxy that overwrites the header, with direct backend access restricted.
Check hosting-panel redirects, CDN rules, and CMS plugins together. An earlier HTTP-to-HTTPS redirect can add a hop before these rules run. Likewise, this snippet does not combine every possible trailing-slash correction. Test the public URL path through the entire stack, including certificate-renewal routes if you change HTTP handling.
Test the journey before making it permanent
Save the previous configuration and validate in staging. You can use R=302 during initial checks, then switch both rules to R=301 once the mapping is settled.
curl -IL --max-redirs 5 'http://www.example.com/index.php'
curl -IL --max-redirs 5 'https://www.example.com/services/index.html?utm_source=test'
curl -IL --max-redirs 5 'https://example.com/services/'Expect one redirect for each old example and a final 200 response. The clean URL should return directly. Inspect each Location header and confirm the query string survives. These commands use HEAD; also check real browser GET requests, page content, and enquiry forms.
Finish by updating internal links, canonical elements, sitemaps, and campaign templates. Record the rules, exceptions, test results, and rollback steps so the next agency can maintain them.
If responsibility is spread across your host, developer, and marketing team, Greg can help coordinate the redirect plan and rollout checks. Bring a few affected URLs and a list of the systems involved.
Related on GrN.dk
- Google’s AI Search Toggle Is a Publishing Decision, Not an SEO Setting
- When Google can call the business, your local data stops being cosmetic
- Cloudflare Page Rules Debt: How Quiet Configuration Drift Breaks Business Websites
Need help with this kind of work?
Discuss your redirect plan with Greg Get in touch with Greg.