Gary Waudby
Gary Waudby

Reputation: 35

Rewrite rule causing a loop

We have an online shop with a welcome page. Our SEO company has asked us to get rid of the welcome page with a rewrite as follows. i am struggling to get this to work. Can you help please?

rewrite www.domain.co.uk/catalog/index.php to become www.domain.co.uk, then 301 from www.domain.co.uk/catalog/index.php to www.domain.co.uk.

I have the following code which causes a redirect loop and nothing is displayed

RewriteRule ^/?$ catalog/index.php [L]
Redirect 301 /catalog/index.php http://www.domain.co.uk

Thanks in advance

Upvotes: 2

Views: 81

Answers (1)

Olaf
Olaf

Reputation: 10247

How's that?

RewriteCond %{REQUEST_URI} /catalog/
RewriteRule .* / [L,R=301]

RewriteRule ^/?$ catalog/index.php [L]

If catalog is part of the browser request, a 301 will correctly redirect to /, which in turn will rewrite to catalog/index.php.

Upvotes: 0

Related Questions