Problem with 301 redirects

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
lprintz
Forum Members
Forum Members
Posts: 76
Joined: Thu Jun 19, 2008 5:59 pm

Problem with 301 redirects

Post by lprintz »

Hello all!

I've installed CMSMS dozens of times but just installed the latest version for a client.

For some reason my 301 redirects aren't working and I simply copied from another client - albeit an older version of CMSMS.

Here's my code...can anybody help me figure out what's going wrong?

Thanks so much!

#Sub-dir e.g: /cmsms
RewriteBase /

RewriteRule ^index.asp$ http://www.jameskeep.com/index.php [R=301,L]
RewriteRule ^users/serview.asp?suid=150$ http://www.jameskeep.com/services/payro ... eping.html [R=301,L]
RewriteRule ^users/serview.asp?suid=151$ http://www.jameskeep.com/services/tax-p ... ation.html [R=301,L]
RewriteRule ^users/serview.asp?suid=340$ http://www.jameskeep.com/index.php [R=301,L]
RewriteRule ^users/serview.asp?suid=153$ http://www.jameskeep.com/privacy-policy.html [R=301,L]
RewriteRule ^users/serview.asp?suid=332$ http://www.jameskeep.com/resources.html [R=301,L]
RewriteRule ^users/serview.asp?suid=6930$ http://www.jameskeep.com/resources.html [R=301,L]
RewriteRule ^users/contactus.asp?suid=6866$ http://www.jameskeep.com/contact-us.html [R=301,L]
RewriteRule ^users/UserSitemap.asp$ http://www.jameskeep.com/sitemap.html [R=301,L]


# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# but ignore POST requests.
#RewriteCond %{REQUEST_URI} !/$
#RewriteCond %{REQUEST_URI} !\.
#RewriteCond %{REQUEST_METHOD} !POST$
#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 ^(.+)$ index.php?page=$1 [QSA]

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Problem with 301 redirects

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
lprintz
Forum Members
Forum Members
Posts: 76
Joined: Thu Jun 19, 2008 5:59 pm

Re: Problem with 301 redirects

Post by lprintz »

Thanks Rolf!

Close! I tweaked the syntax a bit and now the home page and sitemap page works.

I suspect the problem with the other pages are due to the dynamic .asp string - ie users/serview.asp?suid=6930

Can anyone help me with this?

Len
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: Problem with 301 redirects

Post by rotezecke »

is this the entire .htaccess file?

do you have another htaccess file in the users directory?
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Problem with 301 redirects

Post by kerryshamblin »

Hello! I need help in a similar way. I've already tried using the documentation page suggested by Rolf above and then stumbled on this thread. Here is my problem:

I had an existing CMSMS site that wasn't using pretty urls and then I switched it to use pretty urls, while at the same time changing the page alias of a few pages.

Maybe I don't have my RewriteRule in the correct place? Maybe syntax is wrong? I've tried every combination I can with no success. I have cleared cache, still can't get it going.

I want to redirect old address http://www.finnriver.com/index.php?page=farm-visit to http://www.finnriver.com/visit. (I have changed page alias from "farm-visit" to "visit"

Here is my .htaccess:

Code: Select all



# Attempt to override some php settings, these settings may be helpful on some hosts if your
# default configuration does not meet CMS's minimum requirements, and your host
# has given your account appropriate permissions
#php_value upload_max_filesize "10M"
#php_value session_save_path "tmp/cache"

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

# (this is important, so uncomment if your host permit)
#Options -Indexes
#ServerSignature Off

#Options +FollowSymLinks

# To prevent E_STRICT problems with PHP 5.3+ you can uncomment the following lines
# Note: These settings should only be enabled for production sites!
#php_flag display_startup_errors 0
#php_flag display_errors 0
#php_flag html_errors 0
#php_value docref_root 0
#php_value docref_ext 0

<IfModule mod_rewrite.c>
RewriteEngine on

#
#Sub-dir e.g: /cmsms
RewriteBase /

RewriteRule ^index.php?page=farm-visit$ http://www.finnriver.com/visit [R=301,L]

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# but ignore POST requests.
#RewriteCond %{REQUEST_URI} !/$
#RewriteCond %{REQUEST_URI} !\.
#RewriteCond %{REQUEST_METHOD} !POST$
#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 ^(.+)$ index.php?page=$1 [QSA]



</IfModule>

<IfModule mod_header.c>
# Disable ETags
Header unset ETag
FileEtag None
</IfModule>

<IfModule mod_deflate.c>
# Compress css, plaintext, xml, gif, and images in transport.
AddOutputFilterByType DEFLATE text/css text/plain text/xml image/gif image/jpeg image/png
</IfModule>

<IfModule mod_expires.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
# Set expires tags on various files... so that the browser wont attempt to reload them.
ExpiresActive On
ExpiresDefault "access plus 1 year"
<IfModule mod_header.c>
  # Setting cache control to public allowes proxy servers to cache the items too.
  Header set Cache-Control "public"
</IfModule>
</FilesMatch>
</IfModule>
Thank you for your help!
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Problem with 301 redirects

Post by Rolf »

Did you try:

Code: Select all

Redirect 301 http://www.finnriver.com/index.php?page=farm-visit http://www.finnriver.com/visit
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
kerryshamblin
Forum Members
Forum Members
Posts: 87
Joined: Wed Apr 14, 2010 5:21 pm

Re: Problem with 301 redirects

Post by kerryshamblin »

Thank you, Rolf. I just tried that, and it did not work. What I understood is that regular 301 Redirect doesn't work with Pretty URLs.

Where would I put that? Before the mod_rewrite section or after?

I appreciate your help.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: Problem with 301 redirects

Post by rotezecke »

Below are a few links that deal with your problem. basically, mod rewrite does only look at the path to the ?. the rest is ignored.

untested:
RewriteCond %{QUERY_STRING} ^page=farm-visit$
RewriteRule ^index.php /visit? [R=301]
Edit: i just added an ^ and $ for RewriteCond (still untested)

http://wiki.apache.org/httpd/RewriteQueryString
http://stackoverflow.com/questions/2252 ... od-rewrite
http://statichtml.com/2010/mod-rewrite- ... tring.html
Post Reply

Return to “The Lounge”