Results 1 to 7 of 7
  1. #1
    Join Date
    May 2007
    Location
    SW Florida
    Posts
    1,051
    Plugin Contributions
    2

    Idea or Suggestion .htacess rewrite not working

    We just combines several domains to one primary domain. Unfortunately we moved the domain with Zen-Cart domain to a new name.

    I created a domain forward with .htacess and am trying to re-direct the domain index.php requests to the new domain.

    The domain redirect works, but the index.php re-directs are not working.

    I have:

    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^ecabinetpro.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.ecabinetpro.com$
    RewriteRule ^/?$ "http\:\/\/www\.capecabinetdepot\.com\/" [R=301,L]

    # Index Redirect for /index.php with no parameters
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
    RewriteRule ^index\.php$ http://www.capecabinetdepot.com/? [R=301,L]

    # Index Redirect for /(index.php)?main_page=index(&cPath=<blank>) URL
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.php)?\?main_page=index(&cPath=)?\ HTTP/
    RewriteRule ^(index\.php)?$ http://www.capecabinetdepot.com/? [R=301,L]
    What do I need to change to make this seamless?
    JOhn ><>
    Newest Site: ChargerPros - Stuff4Toys

  2. #2
    Join Date
    Mar 2010
    Location
    UK
    Posts
    445
    Plugin Contributions
    0

    Default Re: .htacess rewrite not working

    The last two rules should work OK as coded.

    The first rule should be moved to be last. That rule could also be optimised by changing to:
    Code:
    # Canonical Redirect non-blank, non-www and/or appended port number to www [EXCLUDE /admin requests]
    RewriteCond %{HTTP_HOST}   !^(www\.example\.com)?$
    RewriteCond %{REQUEST_URI} !^/admin [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    http://www.zen-cart.com/forum/showthread.php?t=151606

    Also note; escaping is needed only in patterns, not in the literal target URL.

  3. #3
    Join Date
    May 2007
    Location
    SW Florida
    Posts
    1,051
    Plugin Contributions
    2

    Idea or Suggestion Re: .htacess rewrite not working

    Tried that and it isn't working. URL's like
    http://www.ecabinetpro.com/index.php...dex&cPath=2_90

    Should redirect to
    http://www.capecabinetdepot.com/inde...dex&cPath=2_90

    I have


    RewriteEngine on

    # Index Redirect for /index.php with no parameters
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
    RewriteRule ^index\.php$ http://www.capecabinetdepot.com/? [R=301,L]

    # Index Redirect for /(index.php)?main_page=index(&cPath=<blank>) URL
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.php)?\?main_page=index(&cPath=)?\ HTTP/
    RewriteRule ^(index\.php)?$ http://www.capecabinetdepot.com/? [R=301,L]

    RewriteCond %{HTTP_HOST} ^ecabinetpros.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.ecabinetpros.com$
    RewriteRule ^/?$ "http\:\/\/www\.capecabinetdepot\.com\/" [R=301,L]

    # Canonical Redirect non-blank, non-www and/or appended port number to www [EXCLUDE /admin requests]
    RewriteCond %{HTTP_HOST} !^(www\.ecabinetpro\.com)?$
    RewriteCond %{REQUEST_URI} !^/admin [NC]
    RewriteRule (.*) http://www.capecabinetdepot.com/$1 [R=301,L]

    #Error Page
    #ErrorDocument 403 /403.shtml
    ErrorDocument 404 /404.shtml
    #ErrorDocument 401 /401.shtml
    #ErrorDocument 400 /400.shtml
    #ErrorDocument 500 /500.shtml
    AddLanguage en .en # English

    # RewriteCond %{HTTP_HOST} ^ecabinetpro.com$ [OR]
    # RewriteCond %{HTTP_HOST} ^www.ecabinetpro.com$
    # RewriteRule ^/?$ "http\:\/\/www\.capecabinetdepot\.com\/" [R=301,L]
    Even with the 404.shtml, all I get is "Link Broken"

    Thanks for your advise
    JOhn ><>
    Newest Site: ChargerPros - Stuff4Toys

  4. #4
    Join Date
    May 2007
    Location
    SW Florida
    Posts
    1,051
    Plugin Contributions
    2

    Idea or Suggestion Re: .htacess rewrite not working

    URLs like
    http://www.ecabinetpro.com/index.php

    redirect, but not full paths.
    Newest Site: ChargerPros - Stuff4Toys

  5. #5
    Join Date
    Mar 2010
    Location
    UK
    Posts
    445
    Plugin Contributions
    0

    Default Re: .htacess rewrite not working

    When I said
    Quote Originally Posted by g1smd View Post
    The first rule should be moved to be last. That rule could also be optimised by changing to:
    it meant to replace your code with the new code. You didn't do that. You have used both pieces of code and that is why it does not work. The new code never gets to run as the prior incorrect rule runs first. Delete the bit that is no longer needed.

    Additionally, in that new replacement rule
    Quote Originally Posted by Stuff4Toys View Post
    RewriteCond %{HTTP_HOST} !^(www\.ecabinetpro\.com)?$
    should read
    Code:
    RewriteCond %{HTTP_HOST} !^(www\.ecabinetdepot\.com)?$
    and then it will work. Note that ! means NOT; i.e. if the requested domain is not "exactly" this, then redirect.

    To be clear, delete the third and sixth block of code, and edit the fourth block.
    Last edited by g1smd; 20 Apr 2010 at 07:59 AM.

  6. #6
    Join Date
    May 2007
    Location
    SW Florida
    Posts
    1,051
    Plugin Contributions
    2

    Idea or Suggestion FIXED: .htacess rewrite not working

    Thank You Thank You Thank You that works perfectly! If anyone is looking for this, here is the final code that workes perfectly.


    Code:
     
    RewriteEngine on
    # Index Redirect for /index.php with no parameters
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
    RewriteRule ^index\.php$ http://www.capecabinetdepot.com/? [R=301,L]
     
    # Index Redirect for /(index.php)?main_page=index(&cPath=<blank>) URL
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(index\.php)?\?main_page=index(&cPath=)?\ HTTP/
    RewriteRule ^(index\.php)?$ http://www.capecabinetdepot.com/? [R=301,L]
     
    # Canonical Redirect non-blank, non-www and/or appended port number to www [EXCLUDE /admin requests]
    RewriteCond %{HTTP_HOST}   !^(www\.capecabinetdepot\.com)?$
    RewriteCond %{REQUEST_URI} !^/admin [NC]
    RewriteRule (.*) http://www.capecabinetdepot.com/$1 [R=301,L]
     
    #Error Page
    #ErrorDocument 403 /403.shtml
    ErrorDocument 404 /404.shtml
    #ErrorDocument 401 /401.shtml
    #ErrorDocument 400 /400.shtml
    #ErrorDocument 500 /500.shtml
    AddLanguage en .en # English
    Newest Site: ChargerPros - Stuff4Toys

  7. #7
    Join Date
    Mar 2010
    Location
    UK
    Posts
    445
    Plugin Contributions
    0

    Default Re: .htacess rewrite not working

    Glad you're all fixed up!

    This is server configuration code and it is very unforgiving of logic and/or coding errors.

    Test very carefully.

    Do make sure you change the name of your /admin folder and use that name in the code above. Do not tell anyone in the forum the real name of the admin folder.

 

 

Similar Threads

  1. How do I use htaccess to not rewrite a subdomain?
    By Danielle in forum General Questions
    Replies: 3
    Last Post: 15 Feb 2012, 05:04 AM
  2. Email with Link to a product : URL redirect, rewrite, .htacess?
    By dharma in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 3 May 2007, 10:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg