[solved] redirection

Discussion in 'Apache Migration/Compatibility' started by Galanz, Dec 18, 2016.

  1. Galanz

    Galanz Member

    With apache I made a redirection from root domain to page.html (example.com to exmaple.com/page.html)
    I create an empty file on root directory named page.html
    And I add this lines to .htaccess

    RewriteEngine On
    DirectoryIndex page.html index.php
    DirectoryIndexRedirect seeother
    RewriteRule ^page.html$ index.php [L]
    When I switched to LSWS the redirection stop working

    On /page.html the content is showing but when going to domain root, the redirection to page.html stop working and show the empty page.html

    How to fix that please !

  2. NiteWave

    NiteWave Administrator

    following code should work:

    RewriteEngine On
    DirectoryIndex index.php
    RewriteRule ^page.html$ index.php [L]
    Galanz likes this.
  3. Galanz

    Galanz Member

    A lot of thanks for the answer
    The code partially correct the issue
    Root page is not anymore empty, it's showing correct content
    But I need to fully redirect root to /page.html (example.com to exmaple.com/page.html)
    I mean that the url on browser must be exmaple.com/page.html not exmaple.com
    Hope you understand me
  4. Pong

    Pong Well-Known Member Staff Member

    Any particular reason? Any usage case? What do you want to achieve?

    You may have to decide which is your index page, page.html or index.php. Otherwise, it may make the situation a little complicated without any benefit.
  5. NiteWave

    NiteWave Administrator

    can you try:

    RewriteEngine On
    #DirectoryIndex index.php
    RewriteRule ^$ /page.html [R=301,R]
    RewriteRule ^page.html$ index.php
  6. Galanz

    Galanz Member

    This is it
    Thank you very much :)
  7. NiteWave

    NiteWave Administrator

    happy to know...

    but there is a typo in one line:
    RewriteRule ^$ /page.html [R=301,R]
    should be
    RewriteRule ^$ /page.html [R=301,L]

    RewriteRule ^$ /page.html [R=301,R]
    work well ?
  8. Galanz

    Galanz Member

    I used L from the beginning
    Just tested with R and it seem to work too
    NiteWave likes this.

Share This Page