how to write a .htaccess redirect like stackoverflow does for its questions

后端 未结 2 1656
别那么骄傲
别那么骄傲 2020-12-21 09:51

I\'m trying to write a .htaccess rule that would redirect someone asking for

http://mysite.com/questions/123/my-question-name

to

http://mysite         


        
2条回答
  •  南方客
    南方客 (楼主)
    2020-12-21 10:22

    RewriteRule ^http://([^/]*)/questions/(\d+)/(.*)$ http://$1/questions/question_handler.php?qid=$2

    Your (.*) was probably too greedy so it was using http://mysite.com/questions/123/my-question-name as the first group matched

提交回复
热议问题