Results 1 to 4 of 4

Thread: htaccess RewriteRule

  1. #1
    Join Date
    Dec 2009
    Posts
    2

    Default htaccess RewriteRule

    Currently, I have a script that uses RewriteRule in my htaccess file. It is:

    RewriteRule ^([^/]*)/$ /index.php?go=$1 [L]

    This rule only works for a path such as:
    http://www.mysite.com/473829/

    which redirects to:
    http://www.mysite.com/index.php?go=473829

    What I'm trying to do is create a rule that does not require the last forward slash. That is:

    http://www.mysite.com/473829
    that should redirect to:
    http://www.mysite.com/index.php?go=473829

    Any help will be greatly appreciated.
    Thank You!

  2. #2
    Join Date
    Nov 2006
    Location
    Sydney, Australia
    Posts
    4,944

    Default

    Without the slash it would be

    RewriteRule ^(.*)$ /index.php?go=$1 [L]

  3. #3
    Join Date
    Dec 2009
    Posts
    2

    Default

    Thank you, but I seem to be getting a 500 Internal Server Error. Does this make sense?

  4. #4
    Join Date
    Nov 2006
    Location
    Sydney, Australia
    Posts
    4,944

    Default

    Possibly because now that you are accepting anything the rewritten version also meets the criteria and so gets processed again and again and again until it realises that it can't produce a final result.

    You need something in the content that is to be converted that will not be in the result so that the conversion knows when to stop.

Tags for this Thread

Posting Permissions

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