douwo5710 2015-04-30 23:41
浏览 41

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

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.

  • 写回答

1条回答 默认 最新

  • douzhang1926 2015-04-30 23:58
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条