Hello
I am working on a mod_rewrite rule to lay out new URLs for my site.
Some example URLs for pages:
/media.php
/media.php?p=users
/news.php
/news.php?p=archives
/news.php?p=archives&d=2007-02
/docs.php
/docs.php?p=about
And I want to have the URLs like this:
/media
/media/users
/news
/news/archives
/news/archives/2007-02
/docs
/docs/about
I know that I could have a separate rule for every page on the site, but I want to have one rule that will do the translation to $p=, then just have another rule for pages that need more URL params, like news.
I tried:
However, this rule only works for URLs like
/media
/news
etc
When I try /media/users for ex, it doesn't load proper, and in the log it shows that it translated to /media.php/users
I don't have enough experience with regex and I can't seem to find the documentation that would help me figure this out. Does anyone have a rule that would work for that catch-all?
I am working on a mod_rewrite rule to lay out new URLs for my site.
Some example URLs for pages:
/media.php
/media.php?p=users
/news.php
/news.php?p=archives
/news.php?p=archives&d=2007-02
/docs.php
/docs.php?p=about
And I want to have the URLs like this:
/media
/media/users
/news
/news/archives
/news/archives/2007-02
/docs
/docs/about
I know that I could have a separate rule for every page on the site, but I want to have one rule that will do the translation to $p=, then just have another rule for pages that need more URL params, like news.
I tried:
Code:
RewriteRule ^/(.*)/(.*)$ /$1.php?p=$2
However, this rule only works for URLs like
/media
/news
etc
When I try /media/users for ex, it doesn't load proper, and in the log it shows that it translated to /media.php/users
I don't have enough experience with regex and I can't seem to find the documentation that would help me figure this out. Does anyone have a rule that would work for that catch-all?