Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old April 30th, 2008, 02:16 PM
tcsoul tcsoul is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Location: Asheville, NC
Posts: 14 tcsoul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 45 m 13 sec
Reputation Power: 0
.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?

Reply With Quote
  #2  
Old April 30th, 2008, 02:20 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,124 jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 10 h 58 m 38 sec
Reputation Power: 717
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.

Reply With Quote
  #3  
Old April 30th, 2008, 08:05 PM
tcsoul tcsoul is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Location: Asheville, NC
Posts: 14 tcsoul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 45 m 13 sec
Reputation Power: 0
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]

Reply With Quote
  #4  
Old May 1st, 2008, 09:14 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,124 jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 10 h 58 m 38 sec
Reputation Power: 717
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.

Reply With Quote
  #5  
Old May 1st, 2008, 09:25 AM
tcsoul tcsoul is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Location: Asheville, NC
Posts: 14 tcsoul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 45 m 13 sec
Reputation Power: 0
Quote:
Originally Posted by jharnois
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.


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....

Reply With Quote
  #6  
Old May 1st, 2008, 01:29 PM
tcsoul tcsoul is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Location: Asheville, NC
Posts: 14 tcsoul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 45 m 13 sec
Reputation Power: 0
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?

Reply With Quote
  #7  
Old May 2nd, 2008, 08:14 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,124 jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level)jharnois User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 10 h 58 m 38 sec
Reputation Power: 717
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 ...

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > .htaccess problem combining Wordpress Permalinking and overall site "www" forwarding


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway