The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

help with mod_rewrite.

Discussion in 'General Discussion' started by alexv55, Feb 3, 2011.

  1. alexv55

    alexv55 Registered

    Joined:
    Feb 3, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    I am posting it here after spending over a day and reading apache and docs on the web.

    I am trying to test apache’s rewrite rules directive on. I have sub directory under public_html called wm, which contains test.php and a very simple .htaccess files; nothing fancy.

    # start .htaccess

    RewriteEngine On
    RewriteRule ^wm(/)?$ test.php [NC,L]

    # end .htaccess

    // start test.php
    <?php
    echo ‘hello world’;
    ?>
    // end test.php

    I am expecting it to execute test.php and display ‘hello world’ when I type www.mydomain.co/wm. Instead, I get internet server error message. Also, when I try Business profile for mydomain.co provided by Network Solutions, I still get internal server error.

    I can’t quite put my finger on what’s missing.

    Alex
     
  2. LinuxTechie

    LinuxTechie Well-Known Member

    Joined:
    Jan 22, 2011
    Messages:
    502
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hi Alex.

    It may be an issue with permission or ownership. Please posy your apache error logs which can be found with the help of the command tail -f /usr/local/apache/logs/error_log
     
  3. raghunath

    raghunath Member

    Joined:
    Feb 2, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    You can try this
    ------------------------------------------------------------
    RewriteEngine On
    RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^domainname.com/$ [NC,OR]
    RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^www.domainname.com/$ [NC]
    RewriteRule ^(.*)$ http://www.domainname.com/test.php/$1 [r=301,nc]
    ------------------------------------------------------------

    OR
    Code:
    # Redirect old file path to new file path
    RewriteEngine On
    Redirect /olddirectory/oldfile.html http://domainame.com/newdirectory/newfile.html
     
Loading...

Share This Page