htaccess redirect

Posted on 2011-10-14
Last Modified: 2012-05-12
I need to set up an htaccess file that will redirect from  to and maintain the url in the address bar. I've tried the code below, but it does not do the forwarding. Can someone please let me know how this should be done?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$ / [R=301,L]
Question by:jzilberberg
    LVL 30

    Expert Comment

    by:Brad Howe
    Are you looking to MASK the URL or simply redirect?

    Rewrite rules don't actually hide the query string. They pretty much convert seo friendly urls into the actual domain url + query string

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^$ [OR]
    RewriteCond %{HTTP_HOST} ^$
    RewriteRule ^(.*)$ index.php?section=way&gallery=About&sample=1 [R=301,L,NC]

    The mask the URL would you need to use a iframe or a post page to hide the parameters.

    Best Regards,

    Author Comment

    Ok, thank you. I guess the iframe solution will work for now if there is not a way to mask the url parameters via htaccess.
    LVL 30

    Accepted Solution


    Sorry misunderstood this completely and don't know what i was thinking. You should be able to do it like such with mod_rewrite using an internal redirect.

    RewriteEngine on
    RewriteLog /somefolder/rewrite.log
    RewriteLogLevel 9
    RewriteRule ^/(.*)/?$ /$1/index.php?section=way&gallery=About&sample=1 [PT,NC,QSA,L]

    PT = Forces the resulting URI to be passed back to the URL mapping engine for processing of other URI-to-filename translators, such as Alias or Redirect

    Essentially, a user will request or and get /test/index.php?section......

    browser will still show /test/ but the content in the page will be from index.php.

    Sorry about that, Give this a shot,
    LVL 30

    Expert Comment

    by:Brad Howe
    The logging portion should also be added to the httpd.conf only IF you are having rewrite issues and want to debug.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
    This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmakerā€¦
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now