Page 1 of 1

Individual page redirects?

Posted: Mon Jul 13, 2020 6:55 pm
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 :(

Re: Individual page redirects?

Posted: Mon Jul 13, 2020 7:43 pm
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 /

Re: Individual page redirects?

Posted: Mon Jul 13, 2020 8:37 pm
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.

Re: Individual page redirects?

Posted: Tue Jul 14, 2020 8:11 am
by Rolf