Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Mod_rewrite problems...

  • 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,077 ✭✭✭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,077 ✭✭✭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,077 ✭✭✭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