How to do 301 RDNs?

Hi there,

I have redirected the URLs to my homepage in htacess with this code

RewriteEngine On
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*)$$1 [L,R]

but upon checking the redirect is 302 not 301. How can I fix this?

1 Reply

Based on the information I could find, 302 is a temporary redirect and 301 is permanent. To make your 302 a 301, you'll want to add the following code to the end of your RewriteRule in .htaccess:


According to the folks a,

"this performs a 301 redirect and also stops any later rewrite rules from affecting this URL (a good idea to add after the last rule). It's on the same line as RewriteRule, at the end."

Hope this helps!


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct