Page 1 of 1

Normal 301 redirect commands not working?

Posted: Mon Feb 25, 2008 8:51 pm
by jfin
Hi Guys,

I have recently moved a static site to cms made simple, and for SEO reasons wanted to change the URLs to include keywords, so I figured that I could just add redirect commands to the .htacces file to redirect from the old URL to the new pretty SEO URLs.

EXAMPLE

redirect 301 /old-file-name.htm http://www.domain.com/new-file-name.htm

I have heard that some cms scripts need special code for the 301 redirect to work (Like Drupal)

Can someone point me to the proper code for this to work with cms made simple?

Re: Normal 301 redirect commands not working?

Posted: Tue Feb 26, 2008 1:41 pm
by Pierre M.
Hello,
jfin wrote: redirect 301 /old-file-name.htm http://www.domain.com/new-file-name.htm

I have heard that some cms scripts need special code for the 301 redirect to work (Like Drupal)
No, no special need. This is not CMSms specific. You are redirecting (well) at the webserver level, whatever CMS you are using. There is no need to add something else.

Have fun with CMSms

Pierre M.

Re: Normal 301 redirect commands not working?

Posted: Tue Feb 26, 2008 6:31 pm
by jfin
I figured it out...because I should have included my .htaccess file in the original post so that you could see what was wrong.  I was using mod-rewrite to do my pretty URLs, and had my 301 redirects below the pretty URL commands.

I just put the 301 redirects above the pretty url code and it worked, like below

#php_flag magic_quotes_gpc Off
#php_flag register_globals Off
#php_flag session.use_trans_sid Off

# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On
RewriteBase /

RewriteRule ^oldpage.htm.htm$ http://www.domain.com/newpage.html [R=301,L]

#Rewrites page.shtml as index.php?page
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$

Re: Normal 301 redirect commands not working?

Posted: Wed Apr 16, 2008 11:26 am
by avon_g
Im having the same problem...Ive added the lines to my htaccess but it just shows a 404 error when linking to the bad page.

Heres my htaccess

#php_flag magic_quotes_gpc Off
#php_flag register_globals Off
#php_flag session.use_trans_sid Off

# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On
RewriteBase /

RewriteRule ^/cms/index.php?page=4880-2$ http://www.mydomainco.uk/epson-stylus-pro-4880.html [R=301,L]

#Rewrites page.shtml as index.php?page
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$

Ive taken the / out before cms but dosnt seem to make any difference. I was running cms on IIS but have switched to linux and now using freindly urls so the site is great...just got to get ride of all the bad google links...

Any Ideas?

Regards

Andy

Re: Normal 301 redirect commands not working?

Posted: Wed Apr 16, 2008 5:25 pm
by Pierre M.
Hello,

try first to 301 redirect a simple URL to a static .html page. When this works, try to redirect a sophisticated URL to CMSms.
(and yes, RewriteBase / => no leading / in the RewriteRule)

Pierre M.

Re: Normal 301 redirect commands not working?

Posted: Wed Apr 16, 2008 5:32 pm
by avon_g
Hi Pierre....

Yes I tried what you suggested before I did the post...

RewriteRule ^/?blabla\.html$ blabla.php [L]

which worked ok......Couldnt think where to go after I added the url i actually wanted to redirect and it didnt work...
I did read that if you add the redirect 301 old to new that only works if the new pages is on a different server so that
option is out of the question...

Mod_rewrite is running ok on the server to as i did some tests

Any ideas?

Re: Normal 301 redirect commands not working?

Posted: Wed Apr 16, 2008 6:15 pm
by Pierre M.
May be "?" need encoding like "\." or such little error ?
I don't see why you couldn't redirect like jfin above.
Try a RewriteLog to debug.

Pierre M.