SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow mod rewrite for urls not working?

    hey guys thanks for taking the time to look over my problem and help out!

    Mod rewrite used to work on my website but it no longer is working after some time i am not sure if the original htaccess was replaced by mistake or what but it is no longer working.

    This is my current htaccess file

    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)\.htm$ $1.php [L]
    my urls look like this with out the rewrite

    Code:
    www.domain.com/index.php?done=mypage.php
    and i want them to look like this how they used to with the rewrite

    Code:
    www.domain.com/mypage.htm
    hopefully someone here knows what i am doing wrong thanks for your time!

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,644
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    raven,

    WELCOME to SitePoint's Apache forum.

    How does $1.php get to /index.php?done=mypage.php? What mod_alias redirection is being undone by the RewriteBase statement? Argh!

    Okay, what could have gone wrong? First, can you confirm that mod_rewrite is still working (try the test in my signature's tutorial). After that, then change the .htaccess to:
    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)\.htm$ $1.php [L]
    
    RewriteCond %{REQUEST_URI} !^index\.php$
    RewriteRule ^(.+)\.php index.php?done=$1 [L]
    Regards,

    DK
    Last edited by dklynn; Aug 24, 2010 at 13:55. Reason: Corrected "loopy" code - sorry!
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i sent you a PM i have been reading your articles and doing some testing for the past while i will wait to hear back from you but i think i am making some progress

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,644
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    raven,

    There was no question in the PM. However, you really should post your questions here.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    with the new rewrite when i click links that are like

    www.domain.com/pagename.htm

    they load but give me a page not found


    the site doesnt run on a cms but i was also wondering if i installed and set up wordpress do u think i could 301 the urls and pass google page rank ? to the new pages so google wont tank my seo rating

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,644
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    raven,

    Sorry, noobie error in my code above. PLEASE add the "loop ender" RewriteCond statement to get to your index.php without looping.

    A CMS will add something like the second mod_rewrite block (without the .php extension) so I'm sure that you can do that (save Google page rank) but ONLY IF you preserve the original link (and redirect that correctly). IMHO, though, you'd be better off to R=301 those .htm pages to the correct links within your DMS (and WP does have a nice "use the title" feature which should prove more valuable than preserving the PRs).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  7. #7
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you show me what a 301 looks like code wise for say

    domain.com/pagename.htm

    make the above one redirect to

    domain.com/newpagename

    so the new page has no extension and would be a wordpress page?

    if i can understand based of your example i can create the rest for my other pages as well thanks dklynn

  8. #8
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,644
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    raven,

    That's all in my signature's tutorial - except WordPress and that will depend upon which of their options you select. Just put your code (there ARE examples in the tutorial) before the WP code and you'll be set.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •