Skip to main content

Questions tagged [regular-expression]

A sequence of symbols and characters expressing a string or pattern to be searched for within a longer piece of text.

Filter by
Sorted by
Tagged with
28 votes
2 answers
27k views

Can we use regex in robots.txt file to block URLs?

I have a few dynamic generated URLs. Can I use regex to block these URLs in a robots.txt file?
Sudheera Njs's user avatar
4 votes
1 answer
62 views

.htaccess rule fails when including $ at end

The Basic Situation We have a server. It has some static files, some simple, "flat" .php and .html pages, but it also has a WordPress install at the document root, meaning that visiting / takes the ...
rdm's user avatar
  • 41
4 votes
1 answer
1k views

.htaccess 301 redirect dynamic URL with regex?

How to do this with regular expression? Old -> New http://www.example.com/cat1/cat2/cat3/tool-model-10 -> http://www.example.com/tool/tool-model-10 http://www.example.com/cat1/cat2/cat4/tool-...
Pretzel's user avatar
  • 73
3 votes
1 answer
45k views

How can I get a regular expression to only match an empty string? (In a .htaccess file)

I try to make a regular expression in a .htaccess file, that matches only an empty string. I have tried many things, but it seems like it’s impossible. For example, I tried ^$, but it's looking for ""...
MadsHaupt's user avatar
3 votes
2 answers
225 views

Can't get rewriterule substitution to work

I am trying to use Apache rewrite to turn something like https://www.example.com/sub/?v1=123&v2=456 into https://www.example.com/sub/?v1=789&v2=456 i.e. changing v1 to a specific value ...
Fred Andrews's user avatar
3 votes
1 answer
256 views

Standard WordPress mod_rewrite rules interacting with one of my own rules are causing all requests for a certain page to be sent to the homepage

I have WordPress 3.5.1 installed on Ubuntu 12.04 LTS. I'm running Apache 2.2.22. I can't share the domain that I'm working on, and must sanitize any config files and log outputs. While the website is ...
Wesley's user avatar
  • 254
3 votes
2 answers
4k views

Apache 2.4 <Directory> with regexp - is the alternation operator broken, or am I confused?

I have several document root directories, /opt/lampp/htdocs/proj1, /opt/lampp/proj2, etc, that have AuthType Basic password protection. I want their uploads sub-directory trees not to require a ...
sootsnoot's user avatar
  • 193
3 votes
2 answers
124 views

301 redirect the home pages but keep sitemap pages same

I have manually redirected my entire site. The only page that's left is the homepage. How do I redirect my homepage to the new site (http://example.com) but keep my sitemaps on the old domain (www....
dasickle's user avatar
  • 3,658
3 votes
0 answers
51 views

Filtering Google Analytics pages for Uppercase characters

I'm trying to see if users have accessed URLs with uppercase characters. I have gone into Behavior>Site Content>All Pages and am attempting to filter using Regex. However, my syntax is not ...
Kirsty Simms's user avatar
  • 1,257
2 votes
2 answers
2k views

combine trailing slashes in analytics

Inside my analytics profile, I have to aggregate data from URLs when they are on separate rows because example.com/path is different from example.com/path/. This is a huge usability headache, so I ...
smilebomb's user avatar
  • 317
2 votes
1 answer
444 views

How can I redirect my URL to rearrange the order of subdirectories in .htaccess?

My current URL is example.com/example/{dynamic_id}/{dynamic_name}/static/1.html I want to redirect it to this, example.com/{dynamic_name}/example/{dynamic_id}/static/1.html I tried but failed.
Aatish Kumar's user avatar
2 votes
1 answer
1k views

Google Analytics include traffic only from two sub domains filter

I have a site that has cross-domain tracking setup on it for 4 domains. 2 of those are subdomains from one domain. I have been trying to setup a filter for a view that only includes traffic from those ...
dasickle's user avatar
  • 3,658
2 votes
1 answer
454 views

Apache httpd.conf && .htaccess directives written in PCRE?

I look at the directives syntax of Apache configuration files like httpd.conf && .htaccess and I must say it looks quite similar to PCRE syntax (that stand for Perl Compatible Regular ...
user avatar
2 votes
1 answer
1k views

Google Analytics, filter ALL but a few URL parameters

My sites is being bombarded with new and old URL parameters. At first I tried to add those to the list of excluded URL parameters. With that list now exceeding 200, I wanted to try and use a GA ...
chriscross's user avatar
2 votes
1 answer
2k views

Redirecting one page to HTTPS, and all others back to HTTP isn't working as expected

I have WordPress 3.5.1 installed on Ubuntu 12.04 LTS. I'm running Apache 2.2.22. NOTE: I can't share the domain that I'm working on, and must sanitize any config files. While the website is public, ...
Wesley's user avatar
  • 254
2 votes
1 answer
401 views

Can I use a rewrite rule to send all requests to a single file?

Can I make a single regular expression for all my RewriteRules? I'm rewriting everything to a single file and this this acts like a front-controller. My example: RewriteRule ^de/kontakt/anfahrt$ ...
Denis Jurkovsek's user avatar
2 votes
1 answer
77 views

.htaccess regex 301 redirect after changing site structure?

I`m trying to convert standard 301 redirects using regexp after several changes of categories structures. How to do this with regular expression? Old -> New http://www.example.com/cat1/cat2/cat3/...
Pretzel's user avatar
  • 73
2 votes
1 answer
500 views

How to regex a url to redirect user

Using the regex and the .htaccess file, I want to redirect users to a certain URL. I want to redirect: http://www.example.com/* but not http://www.example.com/CDadmin/* I have tried the following: ...
kpone's user avatar
  • 21
2 votes
1 answer
249 views

How do I build a custom report of referral traffic for a set of domains in google analytics?

I am building links for my client's website and need to make a custom report in google analytics to show traffic only of the links i build. I have tried the following: Set up custom report Define ...
user1721135's user avatar
2 votes
1 answer
1k views

Are regexp advanced filters in Google Analytics Site Content reports supposed to be case sensitive?

When I apply a Matching RegExp advanced filter to a standard Site Content > All Pages report, the regular expression seems to be ignoring case sensitivity. The screenshot attached shows a very ...
DJW's user avatar
  • 23
1 vote
2 answers
774 views

How to parse Apache access log for 404s not from bots?

The regex is easy for 404s in a typical Apache log: grep ' 404 ' access_log But many are coming from bots, which I don't care about. I'm looking for actual people hitting 404s. So I'm trying to ...
jphansen's user avatar
  • 143
1 vote
1 answer
3k views

nginx location rewrite: match /{?x}, {y}, {?z}. Remove y

I am trying to run CiviCRM with Drupal 7 in a docker container of my own design. Unfortunately, I am running into a problem where for some unknown reason CiviCRM is outputting resource requests ...
DMCoding's user avatar
  • 161
1 vote
1 answer
221 views

Google analytics URL filter for URLs with multiple specific dates

I work for a news outlet and would like to filter for URLs containing several dates. Each date would have more than one URL associated. For example I would like a filter that catches all of these: /...
Mark A. Castillo's user avatar
1 vote
1 answer
5k views

How to pass a match from the regex in a condition to the rule in .htaccess

I have an .htaccess file with rules like this: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} /apples/* RewriteRule . /page/faqs.php?cat=apples&...
pg.'s user avatar
  • 133
1 vote
1 answer
2k views

Tracking rotating Ads with Google Tag Manager

So at the moment we have our ads setup using event tracking in Google Analytic (Universal) and they are implemented in this format: <a href="example.com" onclick="ga('send', 'event', 'Banner Ad - ...
dasickle's user avatar
  • 3,658
1 vote
2 answers
415 views

Google Analytics Goal Destination Regex

I'm using a destination goal in Google Analytics to capture region specific success pages (like /en/contact-us/thanks.aspx and /de-DE/contact-us/thanks.aspx), but I would also like to set up a goal ...
Drai's user avatar
  • 777
1 vote
1 answer
106 views

List of events triggered on pages matching regex

Is there a way to get the grouped list of events (such as in Top events) which were triggered on pages matching a regular expression? I may add the Page secondary dimension in Top events and apply ...
Cubius's user avatar
  • 141
1 vote
0 answers
56 views

Google Analytics Regular Expressions Goals with Fragmented Urls

I follow the suggestions of this post: Setting up funnel URLs with regular expressions and in https://regexr.com/ my sample works correctly: The url in question would be like: /cashier\/deposit\/...
Locke's user avatar
  • 301
1 vote
0 answers
192 views

Sum of completed and not completed doesn't add up correctly in the Google Analytics API

I have a simple funnel situation. The users start at /start/ . Some of them reach the result at /result/ and obviously some don't. So it seems logical to me that: users who went to the start page = ...
Steve Eastwood's user avatar
1 vote
1 answer
835 views

Google Analytics Search and Replace filter including request URI parts that have been exluded

I have a search and replace filter that should "roll up" pages underneath different apps. MY URLs have the structure hostname/app-name/page.htm?query App name could be one of several options. My ...
Binarytales's user avatar
1 vote
0 answers
46 views

Regex isn't honored in mod_security2

SecRule REQUEST_URI "^/(|(.*)/)(lpt1|lpt2|lpt3|lpt4)(/|\.|\?|$)" "t:none,t:htmlEntityDecode,t:lowercase,t:removeWhitespace,block,msg:'X',id:'1000'" SecRule REQUEST_URI "^(.*)//(.*)$" "t:none,t:...
Krey's user avatar
  • 11
0 votes
1 answer
56 views

301 redirect doersnt work in SERP

I setup a 301 redirect on my root that points to a new domain. When I type the old domain URL into browser 301 works just fine. When I do a keyword search for my site and click on the link it still ...
dasickle's user avatar
  • 3,658
0 votes
1 answer
286 views

Matching cyrillic characters that look like latin characters?

I would like to identify Cyrillic characters that look like Latin characters and have a list I can refer to. How would I go about that using PHP and regular expressions?
Michael Moriarty's user avatar
0 votes
1 answer
1k views

Google Analytics Funnel Goal Funnel using RegEx

I've created goals using Google Analytics to track the number of pageviews and goal conversions. I have 2 goals in mind. First Goal: User made an appointment without going to other sites > Thank you ...
J. Shi's user avatar
  • 111
0 votes
1 answer
227 views

Regular expression for pages in Google Analytics that matches full words only

I am trying to create a regular expression to see all my landing pages in one search result. This is what I have so far, but this regular expression does not consider the (\W|$)), meaning that I ...
wxT3APyGfkYJVK's user avatar
-1 votes
1 answer
105 views

Advanced GA Filter - What does it do?

I've inherited a website's analytics set up - and there are several filters as in the example below. I'm trying to figure out what they do - but a regex noob.
Kyle's user avatar
  • 11