I would like to redirect everything to a.php. And baba to b.php.
I did the following:
.htaccess :
RewriteEngine on
RewriteCond %{REQUEST_URI} !a.php
RewriteCond %{REQUEST_URI} !baba
RewriteRule .* a.php
RewriteRule baba b.php
a.php : <?php echo 'a.php'; ?>
b.php : <?php echo 'b.php'; ?>
But baba redirect to a.php too.
So I modified line 4 in htaccess to: RewriteCond %{REQUEST_URI} ^!baba
And now baba redirect to b.php but everything else gives a Not found error.
How can I do it?
The rewrite engine loops until the URI going into the engine is the same coming out. The reason why
babais going toa.phpis because it first gets rewritten tob.php, then when the engine loops,b.phpgets rewritten toa.php. You can fix this by adding an additional condition to the first rule:So
b.phpwon’t get rewritten toa.php