Normal 301 redirect commands not working?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
jfin
New Member
New Member
Posts: 5
Joined: Sun Apr 22, 2007 9:01 pm

Normal 301 redirect commands not working?

Post 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?
Don't forget to take your Calcium Supplement and to buy your new mexican home from Costalegre Real Estate
Pierre M.

Re: Normal 301 redirect commands not working?

Post 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.
jfin
New Member
New Member
Posts: 5
Joined: Sun Apr 22, 2007 9:01 pm

Re: Normal 301 redirect commands not working?

Post 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$
Don't forget to take your Calcium Supplement and to buy your new mexican home from Costalegre Real Estate
avon_g

Re: Normal 301 redirect commands not working?

Post 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
Pierre M.

Re: Normal 301 redirect commands not working?

Post 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.
avon_g

Re: Normal 301 redirect commands not working?

Post 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?
Pierre M.

Re: Normal 301 redirect commands not working?

Post 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.
Post Reply

Return to “CMSMS Core”