Help with 301 Re-write

Discussion in 'Apache' started by Wyn James, Apr 20, 2013.

  1. #1
    I have no experience in the area of re-writes, and I have been asked to help out with the aftermath of the move of a website to a new host, where the file structure has been changed.

    The original file structure was as follows:
    http://www.mydomain.co.uk/myfile.php
    HTML:
    The new file structure is:
    http://www.mydomain.co.uk/index.php/myfile.php
    HTML:
    What .htaccess file contents would I need to achieve 301 re-directs from the former to the latter for php and html files only (media files, etc. are unaffected by the move)? I've tried to work this out, but have only managed to get the re-writes to work for specified urls.
     
    Wyn James, Apr 20, 2013 IP
  2. |-:Bharat:-|

    |-:Bharat:-| Well-Known Member

    Messages:
    179
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    145
    #2
    Well basically you can't do that , as Index.php is not an folder ? A file redirecting to some other file will create a redirect loop and results in creating redirect loop errors .
     
    |-:Bharat:-|, Apr 20, 2013 IP
  3. Wyn James

    Wyn James Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    I ended up setting up a whole series of individual page re-writes, which worked fine. However, it caused other problems. I am working on a Magento installation that encompasses three websites. One sits in the root of the hosting account, and the other two websites sit in sub-directories off this root. Many products are shared between websites. The rewrites cause problems for the shared products.

    For the primary domain (that sits in the root) the rewrite primary-domain.co.uk/shared-file.html to primary-domain.co.uk/index.php/shared-file.html works fine. However, the rewrite rule is also having the effect: secondary-domain.co.uk/shared-file.html rewritten to primary-domain.co.uk/index.php/shared-file.html.

    Is there a way of setting up a rewrite condition at the top of .htaccess that has the effect: if the requested url is for the secondary-domain.co.uk then don't proceed further? I've made an attempt at this, using a test against HTTP_HOST without any joy.
     
    Wyn James, Apr 24, 2013 IP