Expression Problem

Hi

I want / and index.php to go index.php page everything other than that go to shop.php but everything is going to shop.php

Here is expressing i am using.

RewriteEngine on
RewriteRule ^/ index.php
RewriteRule [1]([a-zA-Z.]+) shop.php


  1. a-zA-Z ↩︎

I think you need [L] to stop Apache processing / there
RewriteRule ^/ index.php [L]

I assume your DirectoryIndex directive already sets index.php as the directories index file.

“‘last|L’ (last rule)
Stop the rewriting process here and don’t apply any more rewriting rules. This corresponds to the Perl last command or the break command from the C language. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the root-path URL (‘/’) to a real one, e.g., ‘/e/www/’.”

I fixed it:

Solution:


RewriteEngine on
RewriteBase /
RewriteRule ^/?(index\\.php)?$ index.php [L]
RewriteRule ^[a-zA-Z]([a-zA-Z.]+) shop.php

RewriteRule ^/?(index\.php)?$ index.php [L]
Vs
RewriteRule ^(index\.php)?/?$ index.php [L]

Which is more appropriate in your case?