httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rich Bowen <rbo...@rcbowen.com>
Subject Re: [users@httpd] Help On RewriteRule
Date Thu, 11 Aug 2016 12:05:44 GMT


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@rcbowen.com - @rbowen
http://apachecon.com/ - @apachecon


Mime
View raw message