开发者

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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜