duanfei1975 2014-06-26 10:25
浏览 20
已采纳

带有两个URL参数的URL的mod_rewrite

I want to be able to open the following url

http://example.com/login/12345

and in the background, it should load:

http://example.com/index.php?endpoint=login&access_key=12345

Obviously, I have tried many htaccess generators to create an appropriate RewriteRule set.

For example the following (from: http://www.generateit.net/mod-rewrite/index.php):

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /index.php?endpoint=$1&access_key=$2 [L]

Even though I know for a fact that .htaccess and mod_rewrite is enabled on my server (i tried to setup a test to redirect all requests from example.com to example2.com using htaccess and mod_rewrite, and it worked), I can't get this to work.

I have now spent nearly 2 hours to find for a solution on stackoverflow and other websites, but all my attempts failed.

I hope someone can help me find out the correct way to rewrite my url in the above example.like explained above.

Thanks a lot in advance!

  • 写回答

2条回答 默认 最新

  • dongshan3759 2014-06-26 10:32
    关注

    Try with this:

    RewriteEngine On
    RewriteRule ^([^\/]*)/([^\/]*)$ /index.php?endpoint=$1&access_key=$2 [L]
    #-Added-these---^--------^
    

    When tested, here is the result:

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?