Reputation: 3907
i want to page redirection and unable to write condition for it
have different scenario want to redirect friendly url to query string base
http://www.domainname.com/directoryname/friendly-url-goes-here_123456.html
friendly-url-goes-here can be like this friendly_url-goes_23-here_123456.html, i just want 123456
and page get redirected to this
http://www.domainname.com/detail-page?id=123456
123456 will be a variable
Upvotes: 1
Views: 65
Reputation: 786091
You can use this lookahead based regex:
\d+(?=\D*$)
.htaccess:
Inside your root .htaccess you can use this rewrite rule:
RewriteEngine On
RewriteRule ^directoryname/.*?(\d+)\D*$ /detail-page?id=$1 [L,QSA,NC,R]
Upvotes: 4
Reputation: 20024
May be this could be one way to do it:
(\d+).html$
\d+
match a digit [0-9]and this is another way:
\d+(?=\.html$)
(?=.html$)
It is a positive lookahead - it assert that the regex below can be matched if it contains at end($
) a .html
Upvotes: 0