ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

htaccess help

November 07, 2012 8:20am

Subscribe [2]
  • #1 / Nov 07, 2012 8:20am

    Royama Design

    34 posts

    I seem to having an issue with my htaccess and not sure what the proper solution is. Hoping someone here might have an answer.

    When I enter “domain.ca/bob”, I want to be redirected to “www.domain.ca/bob”. Instead, I get “www.domain.ca/index.php/bob”. Not sure why the index.php gets chucked in. Do I have to add something extra to remove the index.php segment? I am already using the remove index.php code in the htaccess.

    RewriteEngine On
    RewriteBase /
    
    # Removes index.php
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    # Redirect for non-domain to www-domain
    rewritecond %{HTTP_HOST} ^domain.ca
    rewriterule ^(.*)$ <a href="http://www.domain.ca/$1">http://www.domain.ca/$1</a> [L,R=301]
    
    # Other redirects below here

    Thanks!

  • #2 / Nov 07, 2012 7:56pm

    John St-Amand

    865 posts

    In the control panel, check in Admin > General Configuration > Name of your site’s index page - do you have index.php in there?

  • #3 / Nov 07, 2012 7:59pm

    John St-Amand

    865 posts

    Ideally you’ll also have your htaccess file remove index.php even if it is present in the URL - so that you don’t have two URLs that display the same thing. Something like:

    # Redirect index.php Requests
    # ------------------------------
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{THE_REQUEST} !/your_system_folder_name/.*
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]

    Hope that helps.

  • #4 / Nov 08, 2012 8:16am

    Royama Design

    34 posts

    Hi John:

    I double checked my general admin settings and I had removed the index.php properly. So not that.

    I don’t really understand the htaccess code fluently. Do you mind taking a moment and describing what your additional code does on each line? How does it differ from what I am currently using?

    Thanks for your help.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases