htaccess Question

Discussion in 'HTML' started by Jeff Thies, Mar 20, 2014.

  1. Jeff Thies

    Jeff Thies Guest

    I have a Wordpress blog on a site that has hardcoded links with the
    complete url.

    I have replicated this onto a mobile subdomain.

    The problem is that when reading the blog from mobile.some-site.com all
    the links point to www.some-site.com. I'd like to rewrite these to
    mobile.some-site.com

    I can't quite wrap my mind around how to do this. I haven't been able to
    do it with HTTP_HOST.

    Jeff
    Jeff Thies, Mar 20, 2014
    #1
    1. Advertising

  2. On Thu, 20 Mar 2014 15:53:18 -0400, Jeff Thies wrote:

    > I have a Wordpress blog on a site that has hardcoded links with the
    > complete url.
    >
    > I have replicated this onto a mobile subdomain.
    >
    > The problem is that when reading the blog from mobile.some-site.com all
    > the links point to www.some-site.com. I'd like to rewrite these to
    > mobile.some-site.com
    >
    > I can't quite wrap my mind around how to do this. I haven't been able to
    > do it with HTTP_HOST.


    If the links in the html files are hard coded in as strings in the text
    like "http://www.some-site.com/blah", I don't think .htaccess on it's own
    will let you dynamically change the file content to replace that with
    "http://mobile.some-site.com/blah", but that might be a lack of my
    knowledge of what .htaccess can do.

    What you could do is edit all the links to change:

    "http://www.some-site.com/blah"

    into:

    "http:/blah"

    and then depending on whether the pages are on the www.x or mobile.x
    site, they'll pick up the relevant links.

    You might be able to redirect all requests processed by www.x that were
    referred from mobile.x back to mobile.x by using something similar to the
    following in .htaccess in the root of www.x

    RewriteCond %{HTTP_REFERRER} mobile.x
    RewriteRule ^(.*) http://mobile.x/$1

    But this will mean that any intentional link from the mobile site to the
    main site will be redirected as well.

    --
    Denis McMahon,
    Denis McMahon, Mar 20, 2014
    #2
    1. Advertising

  3. Jeff Thies

    Jeff Thies Guest

    On 3/20/2014 4:19 PM, Denis McMahon wrote:
    > On Thu, 20 Mar 2014 15:53:18 -0400, Jeff Thies wrote:
    >
    >> I have a Wordpress blog on a site that has hardcoded links with the
    >> complete url.
    >>
    >> I have replicated this onto a mobile subdomain.
    >>
    >> The problem is that when reading the blog from mobile.some-site.com all
    >> the links point to www.some-site.com. I'd like to rewrite these to
    >> mobile.some-site.com
    >>
    >> I can't quite wrap my mind around how to do this. I haven't been able to
    >> do it with HTTP_HOST.

    >
    > If the links in the html files are hard coded in as strings in the text
    > like "http://www.some-site.com/blah", I don't think .htaccess on it's own
    > will let you dynamically change the file content to replace that with
    > "http://mobile.some-site.com/blah", but that might be a lack of my
    > knowledge of what .htaccess can do.
    >
    > What you could do is edit all the links to change:
    >
    > "http://www.some-site.com/blah"
    >
    > into:
    >
    > "http:/blah"
    >
    > and then depending on whether the pages are on the www.x or mobile.x
    > site, they'll pick up the relevant links.
    >
    > You might be able to redirect all requests processed by www.x that were
    > referred from mobile.x back to mobile.x by using something similar to the
    > following in .htaccess in the root of www.x
    >
    > RewriteCond %{HTTP_REFERRER} mobile.x
    > RewriteRule ^(.*) http://mobile.x/$1


    Thanks. I had some trouble working this out as the mobile blog is a
    symbolic link and there were multiple htaccess files to boot. This works:

    RewriteCond %{HTTP_REFERER} mobile\.X\.com/blog [NC]
    rewritecond %{http_host} www.X.com [nc]
    RewriteRule ^(.*)$ http://mobile.X.com/blog/$1 [R=301,L]
    >
    > But this will mean that any intentional link from the mobile site to the
    > main site will be redirected as well.
    >
    Jeff Thies, Mar 22, 2014
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Samuël van Laere

    Charset - htaccess question

    Samuël van Laere, Jul 9, 2003, in forum: HTML
    Replies:
    9
    Views:
    3,554
    T. Audry Glamour
    Jul 9, 2003
  2. Bart van den Burg

    .htaccess question

    Bart van den Burg, Sep 15, 2003, in forum: HTML
    Replies:
    3
    Views:
    464
    Bart van den Burg
    Sep 16, 2003
  3. mentalguy2004

    htaccess question...

    mentalguy2004, Aug 24, 2004, in forum: HTML
    Replies:
    3
    Views:
    407
    lostinspace
    Aug 24, 2004
  4. nllamas

    .htaccess - htm / html question

    nllamas, Apr 1, 2006, in forum: HTML
    Replies:
    3
    Views:
    544
    nllamas
    Apr 1, 2006
  5. BusyGuy

    .htaccess question please

    BusyGuy, Sep 21, 2006, in forum: HTML
    Replies:
    6
    Views:
    503
    Jukka K. Korpela
    Sep 23, 2006
Loading...

Share This Page