News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

www and non www domain

Started by Mirez, December 26, 2017, 03:30:50 PM

Previous topic - Next topic

Mirez

Hi Guys n Girls, looking for help on a problem I'm having with www and non www versions of my site.

QuoteDetails:
Domain - www.fordmpv.com [nofollow]
Host - 1and1.co.uk [nofollow]
SMF Location - root\smf2
index.html in root contains redirect to root\smf2 as no 'site' just the forum

So my problem is that the site is accessible by both www.fordmpv.com [nofollow] and fordmpv.com [nofollow] however I cant find a way to fix this. I read extensively about using rewrite in .htaccess so I added:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^fordmpv.com
RewriteRule (.*) http://www.fordmpv.com/$1 [nofollow] [R=301,L]

However with that in, only the SMF boardindex page works. Any link clicked gets a 404 page. I've confirmed the boardurl is settings.php is the www version so I'm at a loss how to make this work. Any pointers?

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Mirez

Yes. there is no site hosted there its purely the forum and a few subdomains using the rest of the webspace.
Cheers :)

Sir Osis of Liver

Try this -



RewriteEngine on
RewriteCond %{HTTP_HOST} ^fordmpv\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.fordmpv\.com$
RewriteRule ^/?$ "http\:\/\/www\.fordmpv\.com\/smf2\/index\.php\?"
[R=301,L]



Place it in the root, remove index.html.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Mirez

Humm no it didn't like that lol. Resulted in 500 Internal Server Error for all pages :(

Sir Osis of Liver

Should work, it's running on another forum with same setup as yours.  Not on my computer, will check the code tomorrow.  Are you using http or https?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Mirez

Thanks :)

Http, getting this working is part of the work I'm doing in preparation to switch to https

Mirez

Although not part of the problem (for the moment) just to add that trying the forum in https mode using the redirect code:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


I get the same issue as per my first post with this code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^fordmpv.com
RewriteRule (.*) http://www.fordmpv.com/ [nofollow]$1 [R=301,L]


except the pages are just blank non 404, interestingly that's what I now get with the original code  :'(

Aleksi "Lex" Kilpinen

Quote from: Mirez on December 26, 2017, 05:52:33 PM
Humm no it didn't like that lol. Resulted in 500 Internal Server Error for all pages :(
This should leave a line in your server error log, perhaps see if there's a more detailed explanation. It may be something server specific, and as such a good idea to check the log.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Mirez

Thanks, so after some extensive googling with the error log and some more testing I traced the issue back to the prettyurls mod, specifically it creates its own .htaccess file in the forum directory, not the root, and browsers appear to disregard the root file once they see this one.

I disabled prettyurls, deleted its .htaccess file and then converted the site to https. Re-enabled the mod changing the "Pretty URL's Root" variable from www.fordmpv.com/smf2/ [nofollow] to just /smf2
This appears to have fixed it and I now have access for all links and boards on just "https:\\www." so thats good.

Thanks to both above for the help!

I will need to do a little further work as occasionally some files are still being served as http but on the whole its working correctly.

Advertisement: