0

I'm now administering a site for a small professional organisation. The website is hosted with GoDaddy. Most of the links don't work as the site was migrated back from https to http. All of this work predates my involvement.

The .htaccess file is long and complicated with a large number of rewritecond and rewriterule code.

One of the rewrite conditions/rules is working and the others are not. The key difference appears to be that the page direction that is working is to a file that looks like it is located prior to the webroot.

The original file path takes this form: http://TheFileName1.example.com

which is successfully converted to: http://www.example.com/TheFileName10 and shows on the website.

My limited understanding is that the webroot is where the www.example.com is based, so that one would expect TheFileName10 to show inside the webroot.

I can't locate TheFileName10.

Is it likely that this file is stored on the same web hosting server, and why can't I see it?

I'm hoping to use this file as the basis to get the others working. But as I am unable to locate where it is, I'm stuck on fixing the other pages.

Edited to add, parts of the .htaccess file, with content anonymised. I've missed out all the code relating to the FileName[x] 0, 2 through 9 as it duplicates the code for Filename1.

Everything is stored in subfolders under \secure except for FileName10, which I can't locate in the folder structure.

The website was also restructured so that the pages are under the \secure older instead of being directly inside the webroot.

Options +FollowSymLinks
Options -MultiViews
RewriteEngine on
RewriteBase /

# code for website page that works
rewritecond %{http_host} ^TheFileName10\.example\.com [nc]
rewriterule ^$ http://example.com/TheFileName10/ [r=301,L]
rewritecond %{http_host} ^AlternativeFileName10\.example\.com [nc]
rewriterule ^$ http://example.com/TheFileName10/ [r=301,L]
# working code stops here

# code for one of the pages that don't work
rewritecond %{http_host} ^TheFileName1\.example\.com [nc]
rewriterule ^$ http://secure.example.com/TheFileName1/ [r=301,L]
rewritecond %{http_host} ^AlternativeFileName1\.example\.com [nc]
rewriterule ^$ http://secure.example.com/TheFileName1/ [r=301,L]
# this code isn't working stops here

# the website structure is that everything should be situated inside the secure folder
rewritecond %{http_host} ^secure\.example\.com [nc]
rewriterule ^$ http://www.example.com/ [r=301,L]

rewritecond %{http_host} ^(www\.)?secure\.example\.com [nc]
rewriterule ^(.*)$ http://secure.example.com/$1 [r=301,L]

rewritecond %{http_host} ^secure\.example\.com [nc]
rewriterule ^TheFileName$ http://example.com/TheFileName10/ [nc,r=301,L]
rewritecond %{http_host} ^secure\.example\.com [nc]
rewriterule ^TheFileName/$ http://example.com/TheFileName10/ [nc,r=301,L]
rewritecond %{http_host} ^secure\.example\.com [nc]
rewriterule ^TheFileName/(.*)$ http://orsnz.org.nz/TheFileName50/$1 [nc,r=301,L]

rewritecond %{http_host} ^secure\.example\.com [nc]
rewriterule ^(FileName|FileName10|FileName9|FileName8|FileName7|FileName6|FileName5|FileName4|FileName3|FileName2|FileName1|FileName0)$ http://secure.example.com/$1/ [nc,r=301,L]

rewritecond %{http_host} ^secure\.example\.com [nc]
rewriterule ^secure(.*)$ secure$1 [nc,L]

rewritecond %{http_host} ^secure\.example\.com [nc]
rewriterule ^(.*)$ secure/$1 [nc,L]

There seems to be a lot of duplicate conditions and rules.

It is a WordPress site, and I have left out the WordPress code. The .htaccess is 257 lines, including white lines and comments. I am seriously out of my depth. I can read code, I have my own little WordPress site, but I am not used to an .htaccess file this complicated.

  • 1
    Where are you seeing http://TheFileName/www.example.com? In that url, TheFileName would be interpreted as the host name, so the request would go to a server of that name. That isn't a fully qualified domain name, so it shouldn't work. It might work on a local network where the full domain name is automatically added: TheFileName.example.com which then resolves to your server somehow? You need to give us more information so we can help you. – Stephen Ostermiller Jun 3 at 10:46
  • Hi @StephenOstermiller. That construction occurs in the .htaccess file. I'll paste in the parts of the relevant, but anonymised parts of the .htaccess file that appear to be relevant. – Michelle Jun 3 at 23:07
  • I don't actually see http://TheFileName/www.example.com in the .htaccess that you pasted in. I do see TheFileName1\.example\.com which is a subdomain. I edited your question to make the top part match the htaccess file. – Stephen Ostermiller Jun 4 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.