new param in subdomain rewrite

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 21
Joined: 12 Apr 2013, 08:19

new param in subdomain rewrite

14 May 2013, 12:46

Hi Again! Sorry to bugger you.
I got a prob. I have now to add a new parameter to my url rewrite (subdomain):

RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+).mydomain\.com
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/]+)/?$ /dev/index.php?sd=%1&page=$1 [NC]

I want to add &mypg=... like this

RewriteRule ^([^/]+)/?$/...mynewparam.../ /dev/index.php?sd=%1&pg=$1&mypg=$2 [NC]

Thanks in advance.

Cheers,

Yull

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: new param in subdomain rewrite

16 May 2013, 04:59

Please try to fix your rule like this:

RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+).mydomain\.com
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ /dev/index.php?sd=%1&page=$1&mypg=$2 [NC]

User avatar
Posts: 21
Joined: 12 Apr 2013, 08:19

Re: new param in subdomain rewrite

16 May 2013, 10:14

Perfect! many thanks

User avatar
Posts: 21
Joined: 12 Apr 2013, 08:19

Re: new param in subdomain rewrite

16 May 2013, 11:48

Sorry Anton,

I got a new problem.
I can't make both rules work together:
---------------------------------------------
1) RewriteRule ^([^/]+)/?$ /dev/index.php?sd=%1&pg=$1 [NC]
2) RewriteRule ^([^/]+)/([^/]+)/?$ /dev/index.php?sd=%1&pg=$1&mypg=$2 [NC]

My website url base is the first 1) and I need sometime to add a new param like "mypg" but the url base must work all the time.
Find below the url format:
---------------------------------------------
A) http://mysubdomain.mydomain.com/pg/ (my url base)
B) http://mysubdomain.mydomain.com/pg/mypg/ (new param).

If I use the the second 2) rule alone, I have to use second B) format for the whole website and I can't now change my url base.
I have to continue with it.

Any solution?

Cheers,

Yull

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: new param in subdomain rewrite

17 May 2013, 10:21

Please try to fix the rules like this:

RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+).mydomain\.com
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/.]+)/?$ /dev/index.php?sd=%1&pg=$1 [NC,L]

RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+).mydomain\.com
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/.]+)/([^/.]+)/?$ /dev/index.php?sd=%1&pg=$1&mypg=$2 [NC,L]

Note that the RewriteConds affect only ONE RewriteRule directive following them.

User avatar
Posts: 21
Joined: 12 Apr 2013, 08:19

Re: new param in subdomain rewrite

17 May 2013, 11:24

Hi Anton,

Still got a prob!
When I run both togheter, it's taking the data request like below:
http://mysubdomain.mydomain.com/dev/index.php?sd=monseminaire&pg=dev&mypg=index.php

It gives to pg= the dev folder and to mypg= the webpage instead of getting value of

http://mysubdomain.mydomain.com/pg/mypg/ like http://mysubdomain.mydomain.com/1/A/

generating the following url example :

http://mysubdomain.mydomain.com/dev/index.php?sd=mysubdomain&pg=1&mypg=A

Weird!

Any solution?

Cheers,

Yull

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: new param in subdomain rewrite

20 May 2013, 08:15

Let me clarify:

you want to request http://mysubdomain.mydomain.com/1/A/ and want it to show the content of http://mysubdomain.mydomain.com/dev/index.php?sd=mysubdomain&pg=1&mypg=A, right?

Does it not happen?
please enable logging in httpd.conf by putting

RewriteLogLevel 9

and provide rewrite.log records for the test request. rewrite.log is located in ISAPI_Rewrite installation folder.

User avatar
Posts: 21
Joined: 12 Apr 2013, 08:19

Re: new param in subdomain rewrite

21 May 2013, 03:38

Yep, this is exactly what I want!
Making both rules and examples working together :
http://mysubdomain.mydomain.com/1/A/ showing content of
http://mysubdomain.mydomain.com/dev/index.php?sd=mysubdomain&pg=1&mypg=A

and
http://mysubdomain.mydomain.com/1/ showing content of
http://mysubdomain.mydomain.com/dev/index.php?sd=mysubdomain&pg=1

Thanks

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: new param in subdomain rewrite

21 May 2013, 05:07

The rules you currently have should do what you want just fine. One small fix:

RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/.]+)/?$ /dev/index.php?sd=%1&pg=$1 [NC,L]

RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/.]+)/([^/.]+)/?$ /dev/index.php?sd=%1&pg=$1&mypg=$2 [NC,L]

Also please make sure you don't have some other rules in other locations.
And if it still doesn't work, please enable logging in httpd.conf by putting

RewriteLogLevel 9

and provide rewrite.log records for the non-working request.

User avatar
Posts: 21
Joined: 12 Apr 2013, 08:19

Re: new param in subdomain rewrite

22 May 2013, 06:10

Hi Anton!

You small fix works and solves the problem!!
Thanks a lot! ^^

Cheers,

Yull

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 19 guests