0

I have a website running on nginx and my index file is inside a folder. /folder/index.php

I asked my website host to add a "index" directive but they said it is not possible (insecure) and told me to do that by RewriteRule.

So every time that someone type my web address, he need to goes to /folder/file.php

But is not that simple, because I also need that when someone clicks on my banners, I receive the strings from Google URL Builder.

And there is more: my website allows the user to make its own URL, like mydomain.com/user so I already have this RewriteRule:

^/([a-z,0-9,A-Z,_-]+)$  /myhotsite.php?ID=$1
flag: Continue (last)    

The myhotsite.php handles the query and mount the webpage based on a MySQL consult.

So let me try to explain in topics:

  1. mydomain.com -> /folder/file.php
  2. mydomain.com/?utm_source=blablabla -> /folder/file.php/?utm_source=blablabla
  3. mydomain.com/* -> nothing happens, no redirect, it keeps my current rewrite rule that goes to /myhotsite.php?ID=$1

In case 2, I need to keep the query strings, that will go to Google Analytics (as long as I'm concerned, I need to use QSA, but not sure how to)

So, how do you think that we can solve this in the easiest way?

And which rule will have priority: the one that I already have or the one that you will help me to create?

4

1 回答 1

0

1 和 2 都使用以下规则处理:

RewriteRule ^/?$ /folder/file.php [L]

查询字符串会自动附加。你需要把它放在你的其他规则之前。

于 2012-07-05T21:46:10.767 回答