Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6863407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:46:44+00:00 2026-05-27T02:46:44+00:00

Here is my .htaccess file RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^domain\.com RewriteRule ^(.*)$

  • 0

Here is my .htaccess file

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

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^. /archive/index.php [L]

going to domain.com will redirect me to http://www.domain.com

however, going to domain.com/2011/11/18/blog-title will show http://domain.com/var/htdocs/public_html/ instead in the browser URL.

My objective is any page at domain.com will redirect to http://www.domain.com

and wether I go to http://www.domain.com or domain.com /YYYY or /YYYY/MM or /YYYY/MM/DD will pass a PHP REQUEST_URI so I can get data from a MySQL database.

I originally copied the .htaccess file from WordPress but it doesn’t seem to work properly since /var/htdocs/public_html appears in the browser URL bar.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:46:44+00:00Added an answer on May 27, 2026 at 2:46 am

    This will do the trick:

    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    Or this if you want a specific domain:

    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    

    The rules are from Drupal 7 and Drupal 6 respectively and have always worked well for me

    EDIT

    Looking at your code again I think the only problem is that you don’t have a / between http://www.domain.com and $1. Other than that it’s pretty much identical to the second example above which definitely works

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my .htaccess file Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteRule subpage\?sid /index.php
Here's simplified .htaccess file: RewriteEngine On RewriteRule ^index$ index.php On my local lamp server
Here's my .htaccess file: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .*
Here is my .htaccess file RewriteEngine On RewriteRule ^articles/([a-zA-Z0-9_-]+)$ articles.php?article=$1 RewriteRule ^articles/([a-zA-Z0-9_-]+)/$ articles.php?article=$1 This
I am trying to redirect all traffic through index.php. Here is my .htaccess file:
I use http://www.auditmypc.com/xml-sitemap.asp to check if it gets crawled or not. http://www.domain.com/ does NOT
I'm redirecting this URL: http://mydomain.com/expandyourtaste Using this .htaccess file: #Expand your tastes redirects Redirect
The following code inside an .htaccess file is behaving incorrectly.. RewriteEngine on RewriteBase /
Here is the code I have currently in my .htaccess file: Options +FollowSymLinks RewriteEngine
Trying to set 301 redirect in .htaccess file and here is what i am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.