如果页面调用位于子目录中,则移动站点重写规则对于转换后的站点版本无法正常工作

My problem is a little difficult to explain but I think it has to do with the rewrite rules. Basically I have a script that converts a standard site to a mobile site the code is not really supported, by its dev on google code, so I figure I might get some help here I re-coded it a bit so it works with today's phones.

It works fine as long as none of the pages it must access are in a sub so for example the site is www.mysite.com the script is in a sub-domain m.mysite.com the script gets the pages from the main site but appear to be served from the mobile site, a example urls m.mysite.com/mypage.php will work fine and any links on that page do work.

But if the page is in a dir like m.mysite.com/blog/myblog.php it will access that page and you will see /blog in our url but all the links on the page you click will show 404 because they all link as m.mysite.com/myblog.php not m.mysite.com/blog/myblog.php so it does not seem to know that for this page its in /blog even though it is clearly in the url why is it not in the links on the page?

Any ideas what might fix this would this be a rule issue? the htaccess is as follows.

DirectoryIndex phpmobilizer.php

Options +FollowSymlinks
RewriteEngine On

#RewriteCond %{REQUEST_METHOD} =POST
#RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ phpmobilizer.php?url=$1 [QSA]

The other issue I have is if it calls a page with a form it will not post I get 404 if I use the rules I have commented out, if I don't add them it will just reload the page no post. Maybe both problems are somehow related, my hope is some expert can help me sort this all out.

Tried to keep this as short as I could but a tad tricky to explain.

I am not very certain if it works for you. It works in my case with my wordpress page. Try this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?yoururl.com$
RewriteRule ^(/)?$ yoursubdirectory [L]

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/kml/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Cheers

Eric