Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Mod_rewrite problems...

Options
  • 19-01-2009 11:35pm
    #1
    Closed Accounts Posts: 94 ✭✭


    Hi,

    What I'm trying to do is this.

    I want example.com/folder/test.html redirected to http://example.com/folder/file.php?file=test.html

    I want all requests in /folder/ to be rewritten the same way.

    Here is what I have
    RewriteEngine On
    RewriteRule ^folder/([^/\.]+)?$ http://example.com/folder/file.php?url=$1 [L,NC]
    
    example.com/folder/ works, but if I goto example.com/folder/blah.php it doesnt work correctly.

    How should I fix this?

    Thanks!


Comments

  • Subscribers Posts: 4,076 ✭✭✭IRLConor


    RewriteEngine On
    RewriteRule ^folder/([^/[COLOR=RED]\.[/COLOR]]+)?$ http://example.com/folder/file.php?url=$1 [L,NC]
    

    The bit in the red is the issue. You're excluding '.' characters but blah.php includes a '.'.


  • Closed Accounts Posts: 94 ✭✭gnomer


    IRLConor wrote: »
    RewriteEngine On
    RewriteRule ^folder/([^/[COLOR=RED]\.[/COLOR]]+)?$ http://example.com/folder/file.php?url=$1 [L,NC]
    
    The bit in the red is the issue. You're excluding '.' characters but blah.php includes a '.'.
    Ahh,I must have skipped past that. Thanks a lot!


  • Subscribers Posts: 4,076 ✭✭✭IRLConor


    No prob.


  • Closed Accounts Posts: 94 ✭✭gnomer


    Erm, Sorry to to annoy ye again..

    I want to do the opposite this timeee

    I want http://example.com/folder/file.php?file=test.html redirected to example.com/folder/test.html

    Here is what I have
    RewriteRule ^folder/file.php?file=([^/]+)?$ http://example.com/folder/$1 [L]
    

    Yet no luck.

    Anybody help me?

    Thanks!


  • Subscribers Posts: 4,076 ✭✭✭IRLConor


    This is untested, but I'm guessing you need to escape the '?'
    RewriteRule ^folder/file.php[COLOR="Red"]\[/COLOR]?file=([^/]+)?$ http://example.com/folder/$1 [L]
    


  • Advertisement
  • Closed Accounts Posts: 94 ✭✭gnomer


    IRLConor wrote: »
    This is untested, but I'm guessing you need to escape the '?'
    RewriteRule ^folder/file.php[COLOR=Red]\[/COLOR]?file=([^/]+)?$ http://example.com/folder/$1 [L]
    

    Tried that,no difference.

    Thanks for trying.

    Anybody got any other suggestions?


Advertisement