Keavon
Keavon

Reputation: 7493

.htaccess Rewrite Rule Rewrite All Requests From Multiple Directory Depths

I'm using the following code to redirect all requests to one domain to another single page (without stuff after the /)

RewriteEngine on
RewriteRule ^(.*)$ http://example.com [L,R=301]

The above works if I go to olddomain.com or olddomain.com/something, but doesn't work when going to olddomain.com/something/somethingelse

How can I get the rewrite rule to work for all directory depths?

Upvotes: 0

Views: 83

Answers (1)

anubhava
anubhava

Reputation: 784898

Should have worked, You can try this code also:

RewriteRule ^ http://example.com%{REQUEST_URI} [L,R=301]

Upvotes: 1

Related Questions