#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    17
    Rep Power
    0

    .htaccess in not working


    Hi All,

    we have built web site in PHP, Mysql Database and Apache web server. Site is running fine on localhost(Window) but when we try to deploy it on our test environment (ubuntu 12.04.2 platform) .htaccess is not working. I am not getting any error like 500 Internal server error or any thing, index page is loading but after that none of the pages are loading.

    I have enabled mod_rewrite on apache also changed AllowOverride All in /etc/apache2/sites-available/default, still its not working.

    Same files when i deploy on Linux shared hosting is working fine

    Below are the functions which are used in router class
    PHP Code:
    public function loader()
     {

    /*** check the route ***/
    $this->getController();
    /*** if the file is not there diaf ***/
    if (is_readable($this->file) == false)
    {

    $this->file $this->path.'/error404.php';
                    
    $this->controller 'error404';
    }
    /*** include the controller ***/
    require $this->file;
    /*** a new controller class instance ***/
    $class $this->controller 'Controller';
    $controller = new $class($this->registry);
    /*** check if the action is callable ***/
    if (is_callable(array($controller$this->action)) == false)
    {
    $action 'index';
    }
    else
    {
    $action $this->action;
    }

    /*** run the action ***/
    $controller->$action();
     }
     
    /**
     *
     * @get the controller
     *
     * @access private
     *
     * @return void
     *
     */
    private function getController() {


    /*** get the route from the url ***/
    $route = (empty($_GET['rt'])) ? '' $_GET['rt']; 
    if (empty(
    $route))
    {
    $route 'index';
    }
    else
    {
    /*** get the parts of the route ***/
    $parts explode('/'$route);

    $this->controller $parts[0];
    if(isset(
    $parts[1]))
    {
    echo 
    $this->action $parts[1];
    }
    }
    if (empty(
    $this->controller))
    {
    $this->controller 'index';
    }
    /*** Get action ***/
    if (empty($this->action))
    {
    $this->action 'index';
    }

    /*** set the file path ***/
    $this->file $this->path .'/'$this->controller 'Controller.php';


    below is the .htaccess file

    RewriteBase /var/www/pepnew/
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]

    Below is the default file on /etc/apache2/sites-available

    PHP Code:
    <VirtualHost *:80>
            
    ServerAdmin webmaster@localhost

            DocumentRoot 
    /var/www
            
    <Directory />
                    
    Options FollowSymLinks
                    AllowOverride All
            
    </Directory>
            <
    Directory /var/www/>
                    
    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Order allow
    ,deny
                    allow from all
            
    </Directory>

            
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
            <
    Directory "/usr/lib/cgi-bin">
                    
    AllowOverride None
                    Options 
    +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                    Order allow
    ,deny
                    Allow from all
            
    </Directory>

            
    ErrorLog ${APACHE_LOG_DIR}/error.log

            
    # Possible values include: debug, info, notice, warn, error, crit,
            # alert, emerg.
            
    LogLevel warn

            CustomLog 
    ${APACHE_LOG_DIR}/access.log combined

        Alias 
    /doc"/usr/share/doc/"
        
    <Directory "/usr/share/doc/">
            
    Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny
    ,allow
            Deny from all
            Allow from 127.0.0.0
    /255.0.0.0 ::1/128
        
    </Directory>

    </
    VirtualHost
  2. #2
  3. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,302
    Rep Power
    9400
    Well, the most obvious problem I can see is you have the wrong path in your RewriteBase.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    17
    Rep Power
    0
    Originally Posted by requinix
    Well, the most obvious problem I can see is you have the wrong path in your RewriteBase.
    I have changed the rewrite path to /var/www/ but even then its not working
  6. #4
  7. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,302
    Rep Power
    9400
    So to be sure, do pages like /foo and /bar not work while index.php?rt=foo and index.php?rt=bar do?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    17
    Rep Power
    0
    Originally Posted by requinix
    So to be sure, do pages like /foo and /bar not work while index.php?rt=foo and index.php?rt=bar do?
    Yes spot on...
    I am able to post data through
    xyz.com/pepnew/index.php?rt=lms/Login

    but not with
    xyz.com/pepnew/lms/Login
  10. #6
  11. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,302
    Rep Power
    9400

    Moved from PHP


    ...So this all lives under /pepnew? I thought this was in the root. Then that RewriteBase you had before is right.

    Test the .htaccess. Put some random invalid nonsense in it and check that you get a 500 error when trying to browse the site.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    17
    Rep Power
    0
    Originally Posted by requinix
    ...So this all lives under /pepnew? I thought this was in the root. Then that RewriteBase you had before is right.

    Test the .htaccess. Put some random invalid nonsense in it and check that you get a 500 error when trying to browse the site.
    yes i m getting Internal Server Error.....
  14. #8
  15. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,131
    Rep Power
    4304
    Try removing the RewriteBase directive. If that doesn't work, try this one:
    Code:
    RewriteBase /pepnew/
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    17
    Rep Power
    0
    Originally Posted by Kravvitz
    Try removing the RewriteBase directive. If that doesn't work, try this one:
    Code:
    RewriteBase /pepnew/
    Tried with changing rewritebase but still not working...
  18. #10
  19. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,302
    Rep Power
    9400
    Perused the documentation looking for ideas. The other thing I can think of is that the RewriteBase comes after the RewriteRule and might be ignored.

    And RewriteBase, if you must have one at all, should indeed be /pepnew/ and not the full path. It's a URL path, not a file path.

IMN logo majestic logo threadwatch logo seochat tools logo