| Author |
Rewriting /<action>_<number>-my-title.php
|
|
|
| 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
| |
|
| "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
| |
|
| 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
|
|
|
|