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
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
精彩评论