Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using URL rewriting to make my url http://example.com/foo/bar/ to http://example.com/index.php/foo/bar.

I'm not linking the index.php/.. url anywhere, but for some reasons, some users arrives to the index.php url.

In Google analytics, I have a lot of duplicates that are quite annoying to follow up the traffic.

I've watched the Advanced filters but I'm struggling to make it works fine.

Any regex and google analytics pro to help me out ?

share|improve this question
I would run Xenu and check all the links on the page to make sure none are linking to index.php.... I've seen this also happen with shoty PHP programming. IMHO the /index.php/foot/bar/ looks a bit off you should focus on getting example.com/foo/bar/ as your index, first by fixing your code, then set canonical tags as needed. Tell Google in Webmaster Center what your main URL is. – Anagio Oct 20 '12 at 17:15
up vote 1 down vote accepted

You've got the right idea using the advanced filter. If you want to remove the index.php from all entries you should use this:

Remove index.php from Analytics URL's

Google Analytics Advanced Filter 1

Alternatively, if you want to add the index.php to all entries:

Google Analytics Advanced Filter 2

You can read this article for more information

share|improve this answer

How do you know it's a web visitor (as in a human). You will often find that these results are masked by robots and crawlers! Just because you're linking the page within your site today doesn't mean that you didn't in the past (which could be indexed by a search engine or even on a forum or similar) doesn't mean it can't be found.

share|improve this answer
Sure ! By the way my question is how to make Google analytics understand that this is the same URL, not why there is thoses URL. – magnetik Jul 17 '12 at 12:01
Ah, sorry, didn't understand the question. In that case, I don't know, I'm sorry. – Dave Jul 17 '12 at 12:06
no problem ! ;) – magnetik Jul 17 '12 at 12:23
Does this help: webmasters.stackexchange.com/questions/31796/… – Dave Jul 18 '12 at 12:41
Do you know, for sure, if Google Analytics does take this into account ? I don't think so. Moreover, there is a solution to add a filter into GA to make this work, I just don't know how (and that's my question) – magnetik Jul 18 '12 at 15:53

If you have a rewrite rule to rewrite TO the index.php script when "index.php" isn't in the URL, you can have another rewrite rule to redirect away from it when "index.php" is in the URL. I asked on StackOverflow about the mechanics of doing this. You need to use an environment variable with such rewrite rules to prevent infinite loops. Your two rewrite rules would need to look something like this:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule (.*) /index.php/$1 [L,E=LOOP:1]

RewriteCond %{ENV:REDIRECT_LOOP} !1
RewriteRule ^index\.php(\/.*)$ $1 [R,L]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.