Page 1 of 1

[Solved] Pretty Urls won't let me redirect.

Posted: Thu Nov 27, 2008 3:16 pm
by bazzlad
Hey all, quick question but it's been driving me nuts.

I've got pretty urls set up on my cmsms site like below:

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# RewriteCond %{REQUEST_URI} !/$
# RewriteCond %{REQUEST_URI} !\.
# RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).htm$ index.php?page=$1 [QSA] 

RewriteCond %{HTTP_HOST} ^site.com
RewriteRule (.*) http://www.site.com/$1 [R=301,L]

It works fine (most of the time!)

However...
I want to 301 redirect a page say it's called bigbear.htm

When I add this to my .htacess

Code: Select all

redirect 301 /bigbear.htm http://www.site.com/index.htm

It takes me to
www.site.com/index.htm?page=bigbear.htm

Which is actually worse than it was before!

What am I doing wrong?

NB - Doesn't matter what variant I redirect the page to, it happens the same...

Re: Pretty Urls won't let me redirect.

Posted: Thu Nov 27, 2008 4:24 pm
by Nick Smart
Try this:

Code: Select all

[...]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^bigbear.htm$ http://www.site.com/index.html  [R=301,L]
RewriteRule ^(.+).htm$ index.php?page=$1 [QSA] 
[...]


Nick

Re: Pretty Urls won't let me redirect.

Posted: Fri Nov 28, 2008 8:45 am
by bazzlad
Legend!

Thanks a lot mate!

Re: [Solved] Pretty Urls won't let me redirect.

Posted: Fri Nov 28, 2008 1:09 pm
by Pierre M.
Hello,
bazzlad wrote: I want to 301 redirect a page say it's called bigbear.htm

Code: Select all

redirect 301 /bigbear.htm http://www.site.com/index.htm
Please keep on topic, this is not CMSms specific.
The webserver guide tells that redirect/rewrite directives order matters.

BTW, don't show commented out lines when requesting support. We can misread them.

Pierre M.

Re: [Solved] Pretty Urls won't let me redirect.

Posted: Fri Nov 28, 2008 1:18 pm
by bazzlad
Whoa there Pierre!
I apologise for posting this in the wrong place, but in my defence my old 301 redirects worked fine before I installed CMSMS, and used that - which is the recommended .htaccess file for pretty urls, thus I presumed it was a CMSMS issue, an easy mistake to make for somebody following logic who doesn't have a lot of experience using .htaccess.

Also, I left the comments in the code post because that's exactly how it's written on the wiki page, so I wanted to show that it was the generic one recommended.

Again apologies for any ballsup, but I'm sure you can see where I was confused.

Re: [Solved] Pretty Urls won't let me redirect.

Posted: Fri Nov 28, 2008 1:23 pm
by Pierre M.
Thank you, I make mistakes too, obviously.
Have fun with CMSms
Pierre