Individual page redirects?

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
Chris F
Forum Members
Forum Members
Posts: 31
Joined: Wed Jan 28, 2009 3:33 pm

Individual page redirects?

Post by Chris F »

I've been trying to get redirects to work for an old site that I just switched over to a new CMSMS site. I just need to redirect the old URLs that no longer exist (it's the same domain) to some other page that does exist. I've tried redirect and rewrite methods, such as the simple redirect below. If I add more than 1 redirect line it gives me a 500 internal error. I've tried putting them at the top/bottom and several other rewrite codes from various tutorials and help guides but I cannot figure it out.

Code: Select all

<IfModule rewrite_module>

	RewriteEngine on

       Redirect 301 /oldpage/ /index.php?page=newpage
       Redirect 301 /oldpage2/ /index.php?page=newpage2

	# If your CMSMS installation is in a subdirectory of your domain, you need to specify the relative path (from the root of the domain) here.

	# In example: RewriteBase /[subdirectory name]

	RewriteBase /

	

	# Rewrites URLs in the form of /parent/child/grandchild but only rewrites if the requested URL is not a file or directory.

	RewriteCond %{REQUEST_FILENAME} !-f

	RewriteCond %{REQUEST_FILENAME} !-d

	RewriteRule ^(.+)$ index.php?page=$1 [QSA]
	
	

</IfModule>
Any help would be appreciated. I've looked up everything I can find on the web re: htaccess files and I've spent all day trying to get this working :(
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3484
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Individual page redirects?

Post by velden »

According to documentation the last parameter should be a FULL/absolute url:
https://httpd.apache.org/docs/2.2/mod/m ... l#Redirect

In one of my website I use this:

Code: Select all

<IfModule rewrite_module>
	RewriteEngine on
	RewriteBase /
	
	RewriteRule ^aandeel/Ageas_10/$ https://www.domain.com/nl/bel20/ageas [R=301,L]
	RewriteRule ^aandeel/GBL_11/$ https://www.domain.com/nl/bel20/gbl [R=301,L]
	RewriteRule ^aandeel/Engie_12/$ https://www.domain.com/nl/bel20/engie [R=301,L]
Note the first parameter of RewriteRule does NOT start with a /
Chris F
Forum Members
Forum Members
Posts: 31
Joined: Wed Jan 28, 2009 3:33 pm

Re: Individual page redirects?

Post by Chris F »

I've tried it on both servers now (the old one and the new one)..so this works on the old one, domain.com/test/ redirects to test2.

Code: Select all

RewriteRule ^test/$ https://www.domain.com/test2 [R=301,L]
The same code above on the new server results in a 500 internal error. The htaccess file is exactly the same otherwise.

Code: Select all

RewriteRule ^test/$ https://www.domain.com/test2 [R=301,L]

RewriteRule ^anothertest/$ https://www.domain.com/test2 [R=301,L]
If I add a second one, the test/ will go to test2, but anothertest/ just goes to the CMS 404 page.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Individual page redirects?

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Post Reply

Return to “CMSMS Core”