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

  • Home
  • SEARCH
  • 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 7657061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:55:41+00:00 2026-05-31T12:55:41+00:00

Everywhere I look online the htaccess tutorials are all pretty basic. None of them

  • 0

Everywhere I look online the htaccess tutorials are all pretty basic. None of them explain what

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

[NC] and [R=301,L] mean (I can figure the 301 redir tho)

Also where did the %{HTTP_HOST} token come in? What are some others? When was $1 captured? …

Are there any tutorials that explain all of this?

EDIT: Here’s my htaccess file for mguymon:

Options -Indexes
ErrorDocument 404 /404.php
CheckSpelling on

RewriteEngine On
RewriteBase /  
###### Check for alias module to be installed ######

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

###### End www rewrite section ######

# Remove multiple slashes anywhere in URL
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]

# Remove multiple slashes after domain
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]

# show mysite.com/index.php always as mysite.com/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://mysite.com/ [R=301,L]

This will change www.mysite.com/index.php/////index.php to mysite.com which is three rules each with the [L] switch in them

  • 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-31T12:55:43+00:00Added an answer on May 31, 2026 at 12:55 pm

    The Apache .htaccess file uses standard Apache configurations, such as Mod Rewrite. The Mod Rewrite docs explain how RewriteCond and RewriteRule operate.

    I will break down your ModRewrite question:

    RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
    
    • RewriteCond is a conditional to determine if a Rewrite should happen.
    • %{HTTP_HOST} means the RewriteCond is checking the host name of the request
    • ^www\.mysite\.com$ is the pattern, checks if the host name matches http://www.mysite.com
    • [NC] mean no-case, makes the pattern matching case-insensitive

    For example, if someone requests http://www.mysite.com/index.html, the RewriteCond would check the host http://www.mysite.com against the pattern ^www\.mysite\.com$, and since it matches, the following RewriteRule would execute.

    RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]
    
    • RewriteRule is a power tool to rewrite requests
    • ^(.*)$ is the pattern, which will match everything. If the pattern does not match, the RewriteRule will not execute.
    • http://mysite.com/$1 is the rewrite, basically change the request from www.mysite.com to mysite.com.
    • [R=301,L] means the rewrite should send a 301 redirect and be the last rewrite rule to run.

    Continuing the example of http://www.mysite.com/index.html, which passes the RewriteCond, /index.html would match the ^(.*)$ pattern, the rewrite would be set to http://mysite.com/index.html and be sent as a 301 redirect and no further RewriteRules would happen.


    EDIT: Pondering the config

    From my experience, you want all of your redirects at the top of your config. Especially in your cause, were you are trying to normalize your urls, the request will be washed through the series of redirects. Once that is finished, you then do rewrites to serve the correct content. With that in mind, here is a tweaked config of the last 2 rules:

       # show mysite.com/index.php always as mysite.com/
       RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
       RewriteRule ^index\.php$ http://mysite.com/ [R=301,QSA,L]
    
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^/(.*)$ /index.php?a_param=$1 [QSA]   
    

    Off the top of my head I cannot validate the RewriteCond %{THE_REQUEST}, but it looks good. I suspect you want the [QSA] flag which is the query string append. This would cause http://mysite.com/index.php?user=blah to redirect to http://mysite.com/?user=blah. You will want to add QSA to the other redirects if you need to pass along the query strings with the redirect.

    The last rule is determines if index.php should be used versus static content in the directory of the htaccess (directory, images, js, etc). You do not want that as a redirect, but as a rewrite. Do not use a [R] or [L], but add [QSA] again. The pattern matched should be set to a specific parameters passed to index.php.

    This combined with the previous rule would cause http://mysite.com/index.php?user=blah to redirect to to http://mysite.com/?user=blah and then be rewritten so index.php is used for http://mysite.com/?a_page=&user=blah. The request http://mysite.com/a_page?id=7 would be rewritten so index.php is used for http://mysite.com/?a_param=a_page&user=blah

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

Sidebar

Related Questions

Everywhere I look online, it seems that I must use an animation to change
Everywhere I look always the same explanation pop ups. Configure the view resolver. <bean
I'm working on making an ASCII based game, and everywhere I look people are
Everywhere I look there are people who argue vociferously that uninitialised variables are bad
I can't find this information anywhere. Everywhere I look, I find things referring to
I am trying to understand the with statement in python. Everywhere I look it
Everywhere I look, I noticed that both Domain Driven Design (DDD) and entity hydration
I'm starting to see Contexts everywhere I look. In ASP.NET MVC, there are ControllerContexts,
I've look everywhere on how I could remove the image resizing in OpenCart but
Man so much has changed since I learned DirectX 7. Everywhere I look (except

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.