Search code examples
phpwampgenymotion

403 Forbidden error on Genymotion


I installed genymotion emulator on my PC and I want to access my WAMP local server to it and I ran ipconfig on my cmd so I got this IP_address 192.168.56.1 but the problem is that I always get this error

403 Forbidden You don't have permission to access / on this server

I tried all the answers given in this question yet none solved my problem.

I am running Mysql 5.5.8, PHP 5.3.5 and Apache 2.2.17

Please do anyone know how I can fix this error?

@KANAYOAUSTINKANE. This is my code or the Subdomain

<Virtualhost *:80>
    DocumentRoot "C:/wamp/www/mobile"
    ServerName localhost
    ServerAlias m.local host
</Virtualhost>

Please help me out, I have been so disturbed


Solution

  • Okay, here is a solution.

    First step

    Change the location of your virtual host and add a / at the end like this

    DocumentRoot "C:/wamp/www/mobile/"
    

    Second step

    Go to your httpd.conf file located at C:/camp/bin/apache/Apache2.2.17/conf/httpd.conf the go to the line that has Listen 80 and change it to Listen *:80 this will make it to listen to any IP address

    Finally

    You go to the end of your httpd.conf file and add this

    # Tells Apache to identify which site by name
    NameVirtualHost *:80
    # Tells Apache to serve the default WAMP Server page to "localhost"
    <VirtualHost 127.0.0.1>
        ServerName localhost
        DocumentRoot "C:/wamp/www"
    </VirtualHost> 
    # Tells Apache to serve your mobile pages to "m.localhost"
    <VirtualHost 127.0.0.1>
    # The name to respond to ServerName m.localhost
    # Folder where the file is located which in your case is
        DocumentRoot "C:/wamp/www/mobile/"
    <Directory "C:/wamp/www/mobile/">
        Allow from all
        Order Allow,Deny
        AllowOverride All
    </Directory>
    # Apache will look for these files, in this order, if no file is specified in the URL, but you can add more files apart from the two I listed depending on what you are having
        DirectoryIndex index.html index.php
    </VirtualHost> 
    #Here you duplicate the code for your mobile site to also accept your IP address which is 192.168.56.1
    <VirtualHost 192.168.56.1>
    # The name to respond to ServerName m.localhost
    # Folder where the file is located which in your case is
        DocumentRoot "C:/wamp/www/mobile/"
    <Directory "C:/wamp/www/mobile/">
        Allow from all
        Order Allow,Deny
        AllowOverride All
    </Directory>
    # Apache will look for these files, in this order, if no file is specified in the URL, but you can add more files apart from the two I listed depending on what you are having
        DirectoryIndex index.html index.php
    </VirtualHost>
    

    Tested and working. Please don't forget to mark the answer