Web Hosting Forum | Lunarpages

Author Topic: .htaccess + mod_rewrite help - trying to rewrite URLs  (Read 27221 times)

Offline RonRattie

  • Space Explorer
  • ***
  • Posts: 9
    • stillpixelstudios
.htaccess + mod_rewrite help - trying to rewrite URLs
« 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?
stillpixelstudios - no print, just pixels

Offline Mitch

  • Berserker Poster
  • *****
  • Posts: 12641
    • MitchKeeler.com
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #1 on: June 04, 2009, 05:31:47 AM »
Hi Ron!

Are you using a specific script or CMS to control your site?
New to Web Site Hosting? Check Out the Lunarpages Blog Hosting Guide!


Follow us @lunarpages on Twitter!
Important Threads: Read This Before Posting! | Lunarforums Rules! | Mitch's Link of the Day!
Also, be sure to check out and subscribe to the Lunartics Blog and the Lunarpages Newsletter !

Need Web Hosting Help? Check out the Lunarpages Web Hosting Wiki. It has tons of tips, tutorials and resources!

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6229
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #2 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".
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline RonRattie

  • Space Explorer
  • ***
  • Posts: 9
    • stillpixelstudios
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #3 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  (a client who I referred to lunarpages from the other hosting company when I was redesigning the site).
stillpixelstudios - no print, just pixels

Offline Mitch

  • Berserker Poster
  • *****
  • Posts: 12641
    • MitchKeeler.com
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #4 on: June 05, 2009, 03:17:23 AM »
Happy to hear it!   :thumb:
New to Web Site Hosting? Check Out the Lunarpages Blog Hosting Guide!


Follow us @lunarpages on Twitter!
Important Threads: Read This Before Posting! | Lunarforums Rules! | Mitch's Link of the Day!
Also, be sure to check out and subscribe to the Lunartics Blog and the Lunarpages Newsletter !

Need Web Hosting Help? Check out the Lunarpages Web Hosting Wiki. It has tons of tips, tutorials and resources!

Offline RonRattie

  • Space Explorer
  • ***
  • Posts: 9
    • stillpixelstudios
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #5 on: June 05, 2009, 04:47:43 AM »
nice edit Mitch  :notme:
stillpixelstudios - no print, just pixels

Offline Mitch

  • Berserker Poster
  • *****
  • Posts: 12641
    • MitchKeeler.com
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #6 on: June 05, 2009, 04:54:17 AM »
Hmmmm?   :-?
New to Web Site Hosting? Check Out the Lunarpages Blog Hosting Guide!


Follow us @lunarpages on Twitter!
Important Threads: Read This Before Posting! | Lunarforums Rules! | Mitch's Link of the Day!
Also, be sure to check out and subscribe to the Lunartics Blog and the Lunarpages Newsletter !

Need Web Hosting Help? Check out the Lunarpages Web Hosting Wiki. It has tons of tips, tutorials and resources!

Offline RonRattie

  • Space Explorer
  • ***
  • Posts: 9
    • stillpixelstudios
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #7 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...
« Last Edit: June 05, 2009, 10:06:22 AM by Mitch »
stillpixelstudios - no print, just pixels

Offline Mitch

  • Berserker Poster
  • *****
  • Posts: 12641
    • MitchKeeler.com
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #8 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.
New to Web Site Hosting? Check Out the Lunarpages Blog Hosting Guide!


Follow us @lunarpages on Twitter!
Important Threads: Read This Before Posting! | Lunarforums Rules! | Mitch's Link of the Day!
Also, be sure to check out and subscribe to the Lunartics Blog and the Lunarpages Newsletter !

Need Web Hosting Help? Check out the Lunarpages Web Hosting Wiki. It has tons of tips, tutorials and resources!

Offline Mitch

  • Berserker Poster
  • *****
  • Posts: 12641
    • MitchKeeler.com
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #9 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
New to Web Site Hosting? Check Out the Lunarpages Blog Hosting Guide!


Follow us @lunarpages on Twitter!
Important Threads: Read This Before Posting! | Lunarforums Rules! | Mitch's Link of the Day!
Also, be sure to check out and subscribe to the Lunartics Blog and the Lunarpages Newsletter !

Need Web Hosting Help? Check out the Lunarpages Web Hosting Wiki. It has tons of tips, tutorials and resources!

Offline Mitch

  • Berserker Poster
  • *****
  • Posts: 12641
    • MitchKeeler.com
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #10 on: June 05, 2009, 10:07:49 AM »
Either way though, happy to hear you got it taken care of.  :yey:
New to Web Site Hosting? Check Out the Lunarpages Blog Hosting Guide!


Follow us @lunarpages on Twitter!
Important Threads: Read This Before Posting! | Lunarforums Rules! | Mitch's Link of the Day!
Also, be sure to check out and subscribe to the Lunartics Blog and the Lunarpages Newsletter !

Need Web Hosting Help? Check out the Lunarpages Web Hosting Wiki. It has tons of tips, tutorials and resources!

Offline Frederickroofers

  • Newbie
  • *
  • Posts: 1
Re: .htaccess + mod_rewrite help - trying to rewrite URLs
« Reply #11 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.>
« Last Edit: August 01, 2017, 05:51:54 AM by MrPhil »

 

Share |