Web Hosting Forum | Lunarpages

Advanced Lunarpages Assistance => Web Designer's Help and Resources => Topic started by: RonRattie on June 03, 2009, 09:04:16 PM

Title: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: RonRattie on June 03, 2009, 09:04:16 PM
I'm trying to change URLs like www.somesite.com/index.php?page=1 to www.somesite.com/index.htm or www.somesite.com/this_is_a_seo_friendly_url/

I have this

RewriteCond %{QUERY_STRING} ^page=4$
RewriteRule ^contact\.html index.php?page=4 [L]

so far, but it doesn't do anything. I have scoured the net looking for information on how to do this correctly and I am fairly frustrated. :cry:

Anyone have an idea?
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: Mitch on June 04, 2009, 05:31:47 AM
Hi Ron!

Are you using a specific script or CMS to control your site?
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: MrPhil on June 04, 2009, 07:49:40 AM
You're going in the wrong direction. Links on your pages (as well as search engine entries and bookmarks/favorites) should be of the form index.htm. Your .htaccess file should be converting index.htm to index.php?page=1 via URL rewriting. There should be no "QUERY_STRING" in the incoming URL, just "index.htm".
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: RonRattie on June 04, 2009, 01:09:29 PM
You're going in the wrong direction. Links on your pages (as well as search engine entries and bookmarks/favorites) should be of the form index.htm. Your .htaccess file should be converting index.htm to index.php?page=1 via URL rewriting. There should be no "QUERY_STRING" in the incoming URL, just "index.htm".

As is my nature, I posted the question but continued to search and experiment.  I have fixed/solved my problem.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^pjsroofing.com [NC]
RewriteRule ^(.*)$ http://www.pjsroofing.com/$1
RewriteRule ^roof_replacement_and_roof_repair_specialists_serving_maryland_and_pennsylvania\.html index.php?page=1 [L]
RewriteRule ^we_specialize_in_roof_repairs_and_roof_replacement_using_quality_asphalt_cedar_and_metal_products\.html index.php?page=2 [L]
RewriteRule ^take_a_look_at_some_of_our_past_roof_repair_and_roof_replacement_projects\.html index.php?page=3 [L]
RewriteRule ^contact_pjsroofing_for_roof_replacement_or_roof_repairs\.html index.php?page=4 [L]
RewriteRule ^thank_you_for_contacting_pjsroofing_for_your_roof_replacement_or_roof_repairs\.html index.php?page=5 [L]

Quote
Are you using a specific script or CMS to control your site?

no specific scripts were used, just straight up PHP, HTML and CSS.

It is now live at http://www.pjsroofing.com (http://www.pjsroofing.com)  (a client who I referred to lunarpages from the other hosting company when I was redesigning the site).
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: Mitch on June 05, 2009, 03:17:23 AM
Happy to hear it!   :thumb:
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: RonRattie on June 05, 2009, 04:47:43 AM
nice edit Mitch  :notme:
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: Mitch on June 05, 2009, 04:54:17 AM
Hmmmm?   :-?
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: RonRattie on June 05, 2009, 07:49:23 AM
"from the other hosting company" <===  was not what I wrote.


* - edited this as an example

note the note under this...
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: Mitch on June 05, 2009, 10:05:38 AM
"from the other hosting company" <===  was not what I wrote.

Very odd, wasn't edited by me, I'll show you on your previous post what comes up with I edit something.
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: Mitch on June 05, 2009, 10:06:58 AM
"from the other hosting company" <===  was not what I wrote.

Very odd, wasn't edited by me, I'll show you on your previous post what comes up with I edit something.

Last Edit: Today at 01:06:22 PM by Mitch
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: Mitch on June 05, 2009, 10:07:49 AM
Either way though, happy to hear you got it taken care of.  :yey:
Title: Re: .htaccess + mod_rewrite help - trying to rewrite URLs
Post by: Frederickroofers on July 31, 2017, 10:31:33 PM
RewriteEngine on
RewriteCond %{HTTP_HOST} ^<domain.com> [NC]
RewriteRule ^(.*)$ http://www.<domain.com>/$1
RewriteRule ^roof_replacement_and_roof_repair_specialists_serving_maryland_and_pennsylvania\.html index.php?page=1 [L]
RewriteRule ^we_specialize_in_roof_repairs_and_roof_replacement_using_quality_asphalt_cedar_and_metal_products\.html index.php?page=2 [L]

<changed non-LP-hosted domain name, otherwise it's spam -- Mod.>
<what was the question? this looks like a partial copy of RonRattie's post -- Mod.>