htaccess Question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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 all  
the links point to I'd like to rewrite these to

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


Re: htaccess Question

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

Quoted text here. Click to load it

If the links in the html files are hard coded in as strings in the text  
like " ", I don't think .htaccess on it's own  
will let you dynamically change the file content to replace that with  
" ", 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:

" "



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 % 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,

Re: htaccess Question

On 3/20/2014 4:19 PM, Denis McMahon wrote:
Quoted text here. Click to load it

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 % mobile\.X\.com/blog [NC]
rewritecond % [nc]
RewriteRule ^(.*)$ /$1 [R=301,L]
Quoted text here. Click to load it

Site Timeline