Forum Moderators: phranque

Message Too Old, No Replies

Subdomain Mod Rewrite Help

subdomain mod rewrite

         

Darren884

5:24 am on Feb 5, 2005 (gmt 0)

10+ Year Member



Ok, I got the subdomain mod rewrite code to work, however when I do it, and click on any other links on my page it just goes to the same file... so like if I have a link click.html it goes to the same file. Here is my code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomains\.com$ [NC]
RewriteCond %1!^(www)?$ [NC]
RewriteRule!^index\.html$ board_files/file_index.php?board=%1 [NC,L]

What is wrong? How can I fix it?

jdMorgan

6:16 am on Feb 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, you are rewriting any file except /index.html in any subdomain except www to /board_files/file_index.php, and passing the subdomain to that script as a parameter for query variable "board=". So yes, almost all files get rewritten to /board_files/file_index.php

What is it that you really want to do?

Jim

Darren884

6:44 am on Feb 5, 2005 (gmt 0)

10+ Year Member



I want to make it so it only rewriteds one page, so file_index.php for one page, not all.

jdMorgan

4:16 pm on Feb 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please give us more specifics -- Mod_rewrite requires a precise definitioin of the problem to be solved.

What page do you want to rewrite?

Jim

Darren884

9:16 pm on Feb 5, 2005 (gmt 0)

10+ Year Member



file_index.php

However when I am currently doing it now, it rewrites ALL the files in the folder to that one file. How would I just make it write that file, nothing else? So in the future I could precisely rewrite other files? Thanks

jdMorgan

11:31 pm on Feb 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remove the NOT from your RewriteRule, and specify index.php to be rewritten:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomains\.com$ [NC]
RewriteCond %1 !^(www)?$ [NC]
RewriteRule ^index\.php$ /board_files/file_index.php?board=%1 [NC,L]

Jim

Darren884

12:17 am on Feb 6, 2005 (gmt 0)

10+ Year Member



Thank you so much Jim! :D

How would I have it though so if its just the subdomain with no file extension after it goes to file_index.php?

jdMorgan

12:27 am on Feb 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteRule ^(index\.php)?$

Darren884

1:00 am on Feb 6, 2005 (gmt 0)

10+ Year Member



Thanks again Jim! :D

However now I have it like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.mysite\.com$ [NC]
RewriteCond %1!^(www)?$ [NC]
RewriteRule ^(index\.html)?$ /board_files/file_index.php?board=%1 [NC,L]
RewriteRule ^login\.html$ /board_files/file_login.php?board=%1 [NC,L]

and rewrites after the index\.html one are not getting the variable board... what could be wrong?

jdMorgan

1:51 am on Feb 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteConds [httpd.apache.org] and the back-references they create have scope only for the single RewriteRule which follows them. If you need to condition the second rule, then copy the RewriteConds from the first rule.

Jim

Darren884

2:08 am on Feb 6, 2005 (gmt 0)

10+ Year Member



? I dont quite understand what you mean...

jdMorgan

3:01 am on Feb 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In the code posted in message #9 above, the RewriteConds only affect the first rule.

If you want to apply those conditions to the second rule, you will have to copy the RewriteConds from the first rule, and place them ahead of the second rule.

Jim

Darren884

5:25 am on Feb 6, 2005 (gmt 0)

10+ Year Member



Ah ok, I see. Thanks again Jim :D.