duangu9173 2011-09-20 16:25
浏览 20
已采纳

如何为mod_rewrite创建倍数

I have a giant site that I am implementing a mod_rewrite on. This is my first time dealing with this so I'm still working out some major kinks. That being said, I have reg-ex figured out for all of my single pages via:

RewriteRule ^([a-z_-]+)/?$ /$1.php [L,QSA]

which in turn yields something like this:

www.blah.com/page

With the above rule, I have changed my php files to be the same name, except without the .php extension. So for example, the previous pretty url's .php is named page.php

Now, I have made a url goal list for all of my dynamic multi part url pages. Those will ideally look something like this:

www.blah.com/page/extention_of_page/id/title-title 

or

www.blah.com/page/id

Obviously I can't rename each .php for each or when it comes to dynamics it gets a little trickier, so naturally I'm going to categorize my files in folders and feed them that way.

So now that you should have a good idea of what I'm trying to achieve, what would the rewrite rule ( or two ) that would encompass the last two url examples?

thanks in advance

  • 写回答

1条回答 默认 最新

  • duanchanguo7603 2011-09-20 16:43
    关注

    I'd switch around how you're using mod-rewrite.

    Use a 404 page or index page which translates requests.

    Then in mod_rewrite you can pull out each element between / and pass them across...

    index.php?var1=page&var2=extention_of_page$var3=id&var4=title-title

    Then process whats been sent across in the index page and display results accordingly

    Sone good examples here : linky

    However this way kind of implies some DB querying to get the content which from the sound of things is going to be a lot easier to maintain that many differentluy named php files

    HTH

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题