htaccess rewrite regex issue wildcard

This should be fairly easy for all regex gurus, however we are having issues with it.

I need a htaccess rewrite rule for following constellations...

"domain.tld/P123A123B123C123" -> points to index.php?pos=P123A123B123C123

or

"domain.tld/P1A2B3C4" -> points to index.php?pos=P1A2B3C4

...the min length of numbers are 1 and max. length 3 (1-9)

note: a check for chars P A B C to exist on url is required.

--------------Solutions-------------

Hopefully this should work:

RewriteRule domain\.tld\/P\d{1,3}A\d{1,3}B\d{1,3}C\d{1,3}$ index.php?pos=$1

Category:regex Time:2018-08-21 Views:0

Related post

  • .htaccess rewrite regex: match anything but "index" 2009-10-10

    I'm trying to create a rule used in a .htaccess file to match anything but a particular string, in this case: index. I thought that it should be possible to match this special string first and use [L] but that's not working, and it should be possible

  • Htaccess Rewriting URL issue: how to distinguish Listing and detail page 2011-03-15

    I am developing an commerce site, Where users can post items in any categories (categories can be 2 to 4 levels). I want to generate URL for listing and details pages: Listing page will show list of items in inner category Detail Page will show all i

  • Htaccess Rewrite Condition Issue 2011-09-07

    I am trying to follow Paul Irish's example of how to have a built minified version of my site inside /publish. I have successfully integrated the automated build process but can't get the .htaccess file to point to the correct folder. My Aim: When on

  • .htaccess Rewrite Rules "/" issue 2011-11-27

    I have an issue with my .htacess Rewrite Rules... I have the following rule: RewriteRule ^(.+)\/(.+)$ /index.php?pg=$1&cmd=$2 It work, but if I write in the ULR mydomine.com/somthing/something-else/ The resulting $cmd is something-else/ how to re

  • htaccess rewrite rule issue 2012-05-02

    I have a rewrite rule in my htaccess file like in the following example: RewriteRule ^company\/([a-zA-Z0-9]+)\/(.+)$ comp_inf.php?cid=$1 RewriteRule ^company\/([a-zA-Z0-9]+)\/img/(.*)$ ./img/$1 [L] RewriteRule ^company\/([a-zA-Z0-9]+)\/css/(.*)$ ./cs

  • Regex issue in rewriter config 2010-05-25

    I'm having an issue with bad requests from certain search parameters. An example URL: http://www.foo.com/washington/forums/search/%26 Results in a bad request. The rewriter config line looks like this: <rewrite url="^(.*)/forums/search/(.*)" to="~

  • Tips for debugging .htaccess rewrite rules 2012-02-05

    Many posters have problems debugging their RewriteRule and RewriteCond statements within their .htaccess files. Most of these are using a shared hosting service and therefore don't have access to the root server configuration. They cannot avoid using

  • Regular expression to extract target url from a htaccess rewrite rule string in php? 2014-06-03

    I need to check our htaccess rewrite rules if the target url is still ok. For this task I want to be able extract the target part from any rewrite rule. Actually what I need is an appropriate regular expression pattern. Typical htaccess rewrite rules

  • Using an SSL certificate with .htaccess rewrite 2009-10-01

    I'm wondering, if I have an .htaccess rewrite setup on a virtual subdomain, ie. bm.example.com that has a rewrite to www.example.com/index.php?u=someId and I have an SSL certificate on www.example.com, will I run into problems if I try and access htt

  • htaccess rewrite not working for all rules 2009-10-28

    This is a very strange problem, and I just hope that I can clearly explain it. Basically, we made a major update on a client site today, and needed to update some rewrite rules in the htaccess to accomodate the new structure, etc... So, where we orig

  • Mod Rewrite path issues 2009-11-18

    I have successfully created rewrite rules to handle URLs like http://example.com/xyz http://example.com/xyz/ http://example.com/xyz/abc http://example.com/xyz/abc/ Here is the mod rewrite & regex: Options +FollowSymlinks RewriteEngine On RewriteB

  • .htaccess rewritting subdomain + folder to uri 2009-12-20

    I want to redirect this: subdom.mydom.com/mydoc TO mydom.com/subdom/mydoc.php Sorry for being too obvious. I know the htaccess rewritting basis but this is making me a little crazy :) --------------Solutions------------- RewriteBase / RewriteCond %{H

  • htaccess rewrite still some problems, getting a bit complex eek! 2011-04-14

    Another edition to my .htaccess rewriting saga. Everything is now working to a degree but still have some issues. I have numerous rules to move old urls to new urls, passing variables etc - however there are still a couple of things i need to add, an

  • Mod Rewrite Regex - Multiple Negative Lookaheads 2011-07-17

    I currently have the working Mod Rewrite Regex: RewriteEngine On RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^(.*/)?((?:cmd)[^/]*)/((?!(?:cmd)[.+]*)(.+)) $1?$2=$3&%1 [L] That regex takes the following URL and transforms it into the URL immedia

  • htaccess rewrite rule enrute 2 times 2011-09-02

    I have a big problem with .htaccess rewrite rule, my code is this: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] </IfModule> I

  • Getting 404 error when using file_get_contents to scrape html from page that has apache .htaccess rewrite rule 2014-05-26

    I'm trying to scrape rendered html from a drupal 7 site. But I'm unable to target the file with file_get_contents or curl or anything because of a rewrite rule. I always get a "404 file not found" error when trying to load any local file from my serv

  • .htaccess Rewrite Question 2009-05-27

    I have a number of pages in my site, as one would expect. For example: index.php submit.php view.php?id=blah I want these rewritten like index/ submit/ view/blah Whats the best way of doing this? --------------Solutions------------- The ways of handl

  • Making a .htaccess rewrite rule respect subdirectories automatically 2009-10-14

    I'm making a downloadable self-hosted web app (using CodeIgniter), and need the .htaccess rewrite rule to be able to tell if it's in a subdirectory or not to be able to make the rewrite rule correctly. For example, if the app is being installed at ex

  • More HtAccess Rewrite Rules 2010-04-03

    Greetings all, I need help combining some htaccess rewrites, these crazy regular expressions screw with my head. So I have a folder structure something like this: /www/mysite.com/page/member/friends.php /www/mysite.com/page/video/videos.php /www/mysi

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.657 (s). 13 q(s)