1

I have URL domain.com/index.php

I have written this code to redirect to clientarea.php

RewriteEngine On
RewriteRule ^index.php /clientarea.php [R=301]

Now this works except for urls that contain a query string (eg. domain.com/index.php?=something). This will also redirect but I don't want it when there is a query string.

Can anyone tell me how I can do it ?

1
  • I'm not seeing anything about & in your question Commented Jul 20, 2018 at 15:22

2 Answers 2

1

To prevent rewriting when a query string is there

RewriteEngine On

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^index\.php$ /clientarea.php [R=301,L]
Sign up to request clarification or add additional context in comments.

3 Comments

You're welcome, let me update your question to make it clear since some people seem to have a hard time understanding exactly what you meant
See this is done bt why my URLS are replace with clientarea.php, I dont want them instead it should remain same index.php
If you still want to see index.php then you need to remove R=301 flag since you asked it to redirect. Otherwise, it is called a (internal) rewrite
1
RewriteEngine On
RewriteRule ^index.php$ /clientarea.php? [R=301]

$ marks the end of the string in the regex.

1 Comment

no it is not working my url are ending with index.php?m=smd&action=wizard

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.