Apache Server configuration support - Rewriting /<action>_<number>-my-title.php

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > January 2007 > Rewriting /<action>_<number>-my-title.php





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Rewriting /<action>_<number>-my-title.php
Arjen

2007-01-07, 1:18 pm

Hi I have urls that look like
/wid_21-some-text.php
/wid_22-more-words-this-time.php

wich I want to rewrite to

/index.php?wid=21

RewriteRule ^/(.+)_(.+)-(.*).php index.php?&$1=$2 [nc]

gives me
index.php?wid=21-some

How do I catch all words after the first -

Thx !

--
Arjen
http://www.hondenpage.com
HansH

2007-01-07, 7:17 pm

"Arjen" <dont@mail.me> schreef in bericht
news:45a11461$0$64262$dbd4d001@news.wanadoo.nl...
> /wid_21-some-text.php
> /wid_22-more-words-this-time.php
> wich I want to rewrite to
> /index.php?wid=21
>
> RewriteRule ^/(.+)_(.+)-(.*).php index.php?&$1=$2 [nc]
> gives me
> index.php?wid=21-some
>

Feel free to test these ways to stop your backticks at the first seperator
- by using a non-gready regex
RewriteRule ^/(.+?)_(.+?)-(.*).php index.php?$1=$2 [nc]
- by explicitly exclude the respective seperator from the class to match
before
RewriteRule ^/([^_]+)_([^-]+)-(.*).php index.php?$1=$2 [nc]

NOTE: avoid having two pairs of parameters with multiple readable suffixes,
google might ban you for duplicant content.


HansH


Arjen

2007-01-07, 7:17 pm

HansH schreef:
> "Arjen" <dont@mail.me> schreef in bericht
> news:45a11461$0$64262$dbd4d001@news.wanadoo.nl...
> Feel free to test these ways to stop your backticks at the first seperator
> - by using a non-gready regex
> RewriteRule ^/(.+?)_(.+?)-(.*).php index.php?$1=$2 [nc]
> - by explicitly exclude the respective seperator from the class to match
> before
> RewriteRule ^/([^_]+)_([^-]+)-(.*).php index.php?$1=$2 [nc]


Cool Thx !! Ill try that first thing in the morning :-)

> NOTE: avoid having two pairs of parameters with multiple readable suffixes,
> google might ban you for duplicant content.


Yeah ... actually there are atleas 3 duplicate pages for static page.
And 4 for every dynamic page :-)

Im having php check the request uri and add a meta tag not to index the
duplicte pages.

--
Arjen
http://www.hondenpage.com
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com