|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
.htaccess problem combining Wordpress Permalinking and overall site "www" forwarding
I'll start by saying I am by absolutely no means an expert with .htaccess files, though I have used them a lot.
Working with Wordpress permalinking which of course utilizes .htaccess to make it's "pretty"permalinks. All I am looking to do is add a site-wide redirect to ensure that the domain is pushed from the exampledomain.com format to the www.exampledomain.com format. My .htaccess prior to adding the www statements is below, and works just great. Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Redirect 301 /promotions.php http://www.exampledomain.com/promotions
Redirect 301 /register.php http://www.exampledomain.com/register
Redirect 301 /games.php http://www.exampledomain.com/games
Redirect 301 /links.php http://www.exampledomain.com/links
However, when I add the www statement so that the .htaccess contents looks as shown below, the site bombs out. (obviously, I have dropped a dummy domain in this code). Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Redirect 301 /promotions.php http://www.exampledomain.com/promotions
Redirect 301 /register.php http://www.exampledomain.com/register
Redirect 301 /games.php http://www.exampledomain.com/games
Redirect 301 /links.php http://www.exampledomain.com/links
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^exampledomain.com [NC]
RewriteRule ^(.*)$ http://www.exampledomain.com/$1 [L,R=301]
Again, I am sure this is just a syntax thing, but I have no idea where to make changes. Can anybody be of assistance? |
|
#2
|
||||
|
||||
|
You should make this adjustment first, and the following should work regardless of what the domain is (or if it changes):
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^w{3}\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Redirect 301 /promotions.php http://www.exampledomain.com/promotions
Redirect 301 /register.php http://www.exampledomain.com/register
Redirect 301 /games.php http://www.exampledomain.com/games
Redirect 301 /links.php http://www.exampledomain.com/links
__________________
# Jeremy Explain your problem instead of asking how to do what you decided was the solution. |
|
#3
|
|||
|
|||
|
Thanks - That worked perfectly, but in reverse.... I actually want the www prefix, not the other way around. What would the alternate syntax to this look like?
Code:
RewriteCond %{HTTP_HOST} !^w{3}\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
|
|
#4
|
||||
|
||||
|
That's what it should be doing. It's read, if the domain does not begin with "www" then redirect to www.domain. It's Example 6? in the MOD REWRITE sticky.
|
|
#5
|
|||
|
|||
|
Quote:
jharnois, I hope you don't mind, but I just sent you a PM regarding this... Edit: Don't worry about the PM - I am just going to post it here.... ![]() |
|
#6
|
|||
|
|||
|
I'm really confused, I've read through the stickies (now), and you know, it seems to me like this should work. And it's not. Here's my current .htaccess file:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^w{3}\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Redirect 301 /promotions.php http://www.bingosuite.com/promotions
Redirect 301 /register.php http://www.bingosuite.com/register
Redirect 301 /games.php http://www.bingosuite.com/games
Redirect 301 /links.php http://www.bingosuite.com/links
However, if you hit the site , you'll see that the URL is actually being rewritten to the non-www version regardless. I'm rather stumped on this one, as I don't know what else you can use to even rewrite URLs... any ideas? |
|
#7
|
||||
|
||||
|
I don't really work well with PMs. I don't open them and then I forget they're there
![]() It's entirely possible that there's a setting in Wordpress somewhere that tells it to always make it domain.com instead of www.domain.com. Interestingly enough, Firefox's Live HTTP Headers extension doesn't show any of the domain redirecting like I would expect it to do. So when I go to domain.com, it simply requests domain.com. And when I go to www.domain.com, it shows my request was for domain.com. However, on a domain I have that removes the www, I see a request for www.domain.com return a Permanently Moved response followed by another request for domain.com, as expected ![]() I wonder if this could be a DNS / hosting issue ... |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > .htaccess problem combining Wordpress Permalinking and overall site "www" forwarding |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|