Manish Pradhan
Manish Pradhan

Reputation: 1188

Simple Htaccess Regex

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.

Upvotes: 1

Views: 28

Answers (1)

anubhava
anubhava

Reputation: 784918

"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

Upvotes: 1

Related Questions