Re: Help On RewriteRule

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 08/07/2016 06:47 AM, Jayaram Ponnusamy wrote:
> Hi,
> 
> I made below rewriteRule to redirect URL from
> http://cmspweb1.com/sites/en_US/about/newsroom/2015/4 to
> http://cmspweb1.com/sites/en_US/about/newsroom?year=2015&month=4.
> Redirection is happening fine and In Address Bar we are getting From URL
> as expected.
> 
> We have filtering option to select year & Month to view news articles.
> The below rewriteRule help to manually enter the URL, but we would like
> to keep the same as dynamically.
> For example, if User selects year 2010 and month 6 then they should get
> the page with SEO friendly URL in the address bar
> http://cmspweb1.com/sites/en_US/about/newsroom/2010/6 instead of
> http://cmspweb1.com/sites/en_US/about/newsroom?year=2010&month=6
> 
> RewriteEngine On    # Turn on the rewriting engine
> RewriteRule /sites/en_US/about/newsroom/([0-9]+)/([0-9]+)
> sites/en_US/about/newsroom?year=$1&month=$2 [P]
> 

I'm pretty sure you don't want [P] on this. Perhaps you meant [PT]?

I would also recommend that you just make 'newsroom' smarter. That is,
instead of having the 'newsroom' handler expect a QUERY_STRING, have it
read PATH_INFO as well (or instead). In that way, you don't have to
rewrite anything, ever, and you're less prone to error and rewrite failure.


-- 
Rich Bowen - rbowen@xxxxxxxxxxx - @rbowen
http://apachecon.com/ - @apachecon

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux