Kristian
Kristian

Reputation: 1363

301 redirect using htaccess

I had to change the link structure on my site, and to maintain my SEO value I'm trying to setup some 301 rules based on htaccess.

My old setup was this:

http://www.domain.com/news/23/some-text-here

My new setup is this:

http://www.domain.com/read/some-text-here

RewriteCond ^(news)/([0-9]*)/(.*)$
RewriteRule ^(.*)$ http://www.domain.com/read/$3 [L,R=301]

The method above gives me server an internal server error. I hope someone can tell me what I'm doing wrong!

Thanks in advance

Upvotes: 0

Views: 160

Answers (1)

bosmacs
bosmacs

Reputation: 7483

Well for one, you're RewriteCond is missing a string to test against. The basic syntax is

RewriteCond TestString Pattern

For example:

RewriteCond %{REQUEST_URI} ^/(news)/([0-9]*)/(.*)$

See: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond and also make sure the rewrite engine is enabled before anything else:

RewriteEngine On

Upvotes: 1

Related Questions