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
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
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/
Re: [jonoc73] Simple SEO rewrite using htaccess
By Jason - April 20, 2010
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
www.mywebsite.co.uk/detail-1.html
Sorry about all this!
Jono
Re: [jonoc73] Simple SEO rewrite using htaccess
By Jason - April 21, 2010
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/
By Chris - April 28, 2010
Please let me know if I have this right:
1. You have a script called /conditions.php which works fine if you remove the header("Location:...") code which you recently tried adding.
2. You want this script to appear to serve requests that look like /conditions-123.html instead of /conditions.php?123
3. There aren't actually any /conditions-123.html files, you just want to make it appear like they exist.
If that's correct, you'll only need the rewrite rule, not the header("Location:...") code. Your rewrite code looks good, (I tried it myself here and it worked fine,) so if things still aren't working, you could try a simpler rewrite to make sure rewrites are working (e.g. rewrite foo.html to bar.html) or if you have access to httpd.conf [url http://www.latenightpc.com/blog/archives/2007/09/05/a-couple-ways-to-debug-mod_rewrite]you could try turning on rewrite logging[/url] so see if anything is going awry.
I'm afraid there isn't too much else we can do here on the forums, but our consulting team could probably get this figured out for you if all else fails. Please let me know if you're interested in that.
I hope this helps. Please let us know how it goes or if you have any questions.
Chris
Simple SEO rewrite using htaccess
By (Deleted User) - May 5, 2010
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