Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-17-2012, 10:11 PM   PM User | #1
mathceleb
Regular Coder

 
Join Date: Mar 2010
Posts: 235
Thanks: 39
Thanked 6 Times in 6 Posts
mathceleb is an unknown quantity at this point
Redirect Issue

When we use the following .htaccess the site will redirect properly for a few minutes then it just stops responding. Essentially, we want to redirect non-www requests to the www handle.

Code:
BrowserMatchNoCase Apache-HttpClient/4.0.1 bad_bot
Order Deny,Allow
Deny from env=bad_bot

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.mysite\.com
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L] 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
mathceleb is offline   Reply With Quote
Old 07-18-2012, 11:34 AM   PM User | #2
MarkR
New Coder

 
Join Date: Sep 2011
Posts: 80
Thanks: 0
Thanked 13 Times in 12 Posts
MarkR is an unknown quantity at this point
Try the inverse:

Code:
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [L,R=301,L]
__________________
Web Design Newcastle
MarkR is offline   Reply With Quote
Users who have thanked MarkR for this post:
mathceleb (07-18-2012)
Old 08-28-2012, 06:28 PM   PM User | #3
handlegeek
New to the CF scene

 
Join Date: Aug 2012
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
handlegeek is an unknown quantity at this point
Below code works well for non-www to www redirects.

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
You can refer here:
http://www.ganeshbabujayaraman.com/a...and-drupal-cms
handlegeek is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:48 AM.


Advertisement
Log in to turn off these ads.