1

I have the following code in my .htaccess file in the folder

http://localhost/modrewrite/test/

RewriteCond %{REQUEST_URI} ^modrewrite/.*$
RewriteRule b.html [L]

All I want to do is whenever I go to index.php in that above folder, i want it redirected to b.html. I know this can be done by just using

RewriteEngine on
RewriteRule index.php b.html [L]

but I want to use RewriteCond and %{REQUEST_URI} to see how it actually works. Thanks.

1 Answer 1

1

"I want to use RewriteCond and %{REQUEST_URI}"

You can try this rule:

RewriteEngine on

RewriteCond %{REQUEST_URI} index\.php
RewriteRule ^ b.html [L]

Though I will suggest that other rule is much cleaner i.e.

RewriteRule ^index\.php$ b.html [L,NC]

Reference: Apache mod_rewrite Introduction

Sign up to request clarification or add additional context in comments.

Comments

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.