Simple SEO rewrite using htaccess - SOLVED

18 posts by 4 authors in: Forums > CMS Builder
Last Post: May 5, 2010   (RSS)

By (Deleted User) - April 20, 2010

The original page is:

http://www.mywebsite.co.uk/conditions.php?detailpage-1

with this code at the top:
<?php
$location = "/conditions/".$_SERVER['QUERY_STRING'].".html";
header("Location:$location");
?>


It changes to:
http://www.mywebsite.co.uk/conditions/detailpage-1.html

but gives a 404 error page.

Location of file:
/home/sass/public_html/cmsAdmin/lib/viewer_functions.php

Is that the info you needed?

Jono

Re: [jonoc73] Simple SEO rewrite using htaccess

By Jason - April 20, 2010

Hi,

The file detailpage-1.html, where is that? Is it in the same folder as conditions.php or is it in a folder called conditions?

If it's in a folder called conditions, is that folder in the same folder as conditions.php?

Let me know.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By (Deleted User) - April 20, 2010

they are all at the root of the domain.

J

Re: [jonoc73] Simple SEO rewrite using htaccess

By Jason - April 20, 2010

Okay, that would be the problem.

Our original solution redirected to a folder called conditions :
www.mywebsite.co.uk/conditions/detail-1.html.

Since there isn't a conditions folder, try this:
<?php
$location = $_SERVER['QUERY_STRING'].".html";
header("Location:$location");
?>


Give that a try.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By (Deleted User) - April 21, 2010

I'm afraid that too gives a 404 error as it directs to:

www.mywebsite.co.uk/detail-1.html

Sorry about all this!

Jono

Re: [jonoc73] Simple SEO rewrite using htaccess

By Jason - April 21, 2010

If you find detail-1.html and open it, what is the url it gives? What is the url of conditions.php?

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Simple SEO rewrite using htaccess

By (Deleted User) - May 5, 2010

Jason has done loads to help on this one and has come up with the correct results:

Add this to the htaccess file and it gets rid of the .php?

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteRule ^conditions/([^\.]+)$ conditions.php?id=$1 [NC,L]

Thanks Jason for all your help!

Jono