Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mod-rewrite gives me http://localhosthttp://localhost/...

    I'm using the following RewriteRules to generate nicer URIs for my blog, but I'm running into problems:
    Code:
    RewriteEngine On
    RewriteBase /
    RewriteRule ^http://localhost/archives/?([0-9]{4})?/?([0-9]{1,2})?/?([0-9]{1,2})?/?([0-9a-z-]+)?([0-9]+)?/?$ /index.php?year=$1&monthnum=$2&day=$3&name=$4&page=$5 [QSA]
    RewriteRule ^http://localhost/archives/category/?(.*) /index.php?category_name=$1 [QSA]
    (I don't actually understand .htaccess, this was generated by WordPress for me).

    However, when clicking on a link that would normally take me to http://localhost/index.php?id=7, it's rewritten to http://localhosthttp//localhost/arch...6/header-test. I thought it odd that the second http://localhost doesn't have a colon... could that be relevant?

    TIA.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    i've also been messing around with mod_rewrite just recently, and although i'm nothing close to sure, i think that you don't want the http://localhost bit in there. try it as this:

    Code:
    RewriteEngine On
    RewriteBase /
    RewriteRule ^archives/?([0-9]{4})?/?([0-9]{1,2})?/?([0-9]{1,2})?/?([0-9a-z-]+)?([0-9]+)?/?$ /index.php?year=$1&monthnum=$2&day=$3&name=$4&page=$5 [QSA]
    RewriteRule ^archives/category/?(.*) /index.php?category_name=$1 [QSA]
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, that was my first stab too, and it doesn't work. I still get the same link. Thanks for trying.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #4
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    yeah, i think your answer is gonna be a combination of things, though i don't know which combination.

    the other thing you might try is dropping the [QSA] from the end; that messes with url query strings in ways that i won't pretend to completely understand, but i'm about 90% you don't need it.

    also, for the time being, try commenting out the regular expressions, and see if it works with a single page. like

    Code:
    RewriteEngine On
    RewriteBase /
    RewriteRule ^archives/example.htm$ /index.php?example
    then, if that works, try using a really simple RegEx, like maybe just ^(.*)$, see if it works, and work up from there. it will most likely turn out to be a terribly giant pain in the butt, but it's what i ended up doing. from the tutorials and docs that i've read, this is more of an art than a science, so a huge pain in the butt is the best you can hope for.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #5
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, after thinking about this a bit more, I figured it wasn't Apache's fault, the faulty URI was in fact being written straight into my page. I hopped through WordPress's function files and found the function. After a bit of editing, I found that WordPress was in fact, perfect, and it was my fault — I had my permalink options set up wrong .

    For future reference: those of you using WordPress's fancy mod-rewrite URL functions, don't include your base url (eg http://localhost/ for me) when creating the 'virtual site structure' under Permalink Options, in options.

    joh6nn, thanks for your help.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!


  •  

    Posting Permissions

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