Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
redirect url exact match with htaccess like case sensitive

redirect url exact match with htaccess not redirect if query string or anything after index.php

Redirect This Page: https://example.com/demo/index.php
To Page: https://example.com/ (home page)

But Do Not redirect: https://example.com/demo/index.php/*

 Do NOT redirect: https://example.com/demo/index.php/password

 Do NOT redirect https://example.com/demo/index.php?m=page
  not redirect if any other combination 

only redirect https://example.com/demo/index.php to https://example.com/

this script not working

RewriteEngine On
RewriteBase /
RewriteRule ^demo/index.php /demo/index.php?m=page[L,NC,END]
RewriteRule ^demo/index.php$ https://example.com/ [L,R=301]
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

only redirect https://example.com/demo/index.php to https://example.com/

If you only want to redirect that exact URL, without a query string then you need to reverse your existing rules and include an additional condition that checks that the QUERY_STRING is empty. The RewriteRule only matches against the URL-path, which excludes the query string.

You are also missing a space before the flags argument in the first rule.

For example:

# Redirect exact URL to home page
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^demo/index\.php$ / [R=302,L]

# Redirect other URLs with query string OR path-info
RewriteRule ^demo/index\.php /demo/index.php?m=page [NC,L]

You don't need L and END.

Test with 302, and change to 301 only once you have confirmed it works OK. To avoid caching issues.

over 4 years ago · Santiago Trujillo Report

0

You may use these rules in site root .htaccess:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+demo/index\.php\s [NC]
RewriteRule ^ / [L,R=301]

RewriteRule ^demo/index\.php$ $0?m=page [QSA,NC,L]
over 4 years ago · Santiago Trujillo Report

0

This was created by htaccess redirect generator I use very often.

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^demo/index\.php$ https://example.com/? [R=301,L]

Maybe "?" sign is redundant because of empty query string match.

Not sure, but You also can try to add

RewriteCond %{REQUEST_METHOD} !=POST 

in case You can't log in. All together:

RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^demo/index\.php$ https://example.com/? [R=301,L]
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!