Welcome to WebmasterWorld Guest from 188.8.131.52 , register , free tools , login , search , subscribe , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor
htaccess with multiple variables RewriteRule ^news/?(.*)/?(.*)$ index.php?page=news&article=$1&pagenum=$2 MikeElmore msg:4327704 8:44 am on Jun 18, 2011 (gmt 0) ok so I have this site where the following variables are being passed through the url: index.php?page=something based on what 'something' is will determine other variables to be passed, for example: if something = news then pass $article and $pagenum This is my htaccess rule for this:
RewriteRule ^news/?(.*)/?(.*)$ index.php?page=news&article=$1&pagenum=$2 [NC,L]
This works fine for: url.com/news url.com/news/main - this passes article=main however: url.com/news/main/2 - passes article=main/2 instead of article=main pagenum=2 can someone please help me out?
phranque msg:4327713 9:26 am on Jun 18, 2011 (gmt 0)
welcome to WebmasterWorld, MikeElmore! the .* pattern is "promiscuous, ambiguous and greedy", so the first ".*" in your pattern will match everything after "news/" and the "/?(.*)$" pattern will match "nothing" at the end of the current URL. check out this thread which should give you some good clues for your solution. rewriterules for multi-level folders: http://www.webmasterworld.com/forum92/3771.htm [ webmasterworld.com] [
edited by: phranque at 9:46 am (utc) on Jun 18, 2011] g1smd msg:4327715 9:40 am on Jun 18, 2011 (gmt 0)
The /? makes the slash optional. Combined with the .* pattern the parser has NO idea what you actually want. You'll need separate rules for different folder depths. The NC flag promotes Duplicate Content within your site. Ensure your script checks that requests are correctly cased and issues a redirect to the correct URL if not.