0

What I have

I have a domain configured to point to my server.

When I go to my domain, let's say:

example.com

it redirects me to:

http://104.286.131.72/mysitefolder/index.php?

And of course, it shows me the right site.

I have apache for this, and a file called /etc/apache2/sites-enabled/000-default.conf with this content:

<VirtualHost *:80>
        DocumentRoot /var/www/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:80>
        DocumentRoot /var/www/mysitefolder/
        ServerName example.com
        ServerAlias www.example.com
</VirtualHost>

What I want

When I go to my domain:

example.com

it redirects me to:

http://example.com/index.php?

And showing me the same site.

How can I do that?

Update1

Tried to change the second block to @imvikasmunjal answer and I git this:

The requested URL /mysitefolder/index.php was not found on this server.

The /var/log/apache2/access.log file says:

190.126.199.244 - - [25/Apr/2016:01:43:43 -0400] "GET /mysitefolder/index.php? HTTP/1.1" 404 521 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

Update2

I have an .htaccesslike this:

#Domain: 104.286.131.72
RewriteRule . - [E=REWRITEBASE:/mysitefolder/]
RewriteRule ^api$ api/ [L]

RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
</IfModule>
....
6
  • In the first virtual host, Try providing ServerName default & reload Apache and also do you have any .htaccess redirects in /var/www/mysitefolder/ ? Apr 25, 2016 at 5:53
  • This is most likely configured in whatever web app you try to run on that machine.
    – Sven
    Apr 25, 2016 at 5:59
  • @serverliving.com thank you, I updated my question with the htaccess file. I created a Hello world html site and it worked with your suggestions but my main site doesn't work so definitely is something with the .htaccess file but still not sure what exactly it is. Apr 25, 2016 at 6:04
  • I think you don't require this rule RewriteRule . - [E=REWRITEBASE:/mysitefolder/] since your DocumentRoot is already pointing to /var/www/mysitefolder/ . You can try commenting this rule Apr 25, 2016 at 6:10
  • I completely delete this file and generated again with my app as @Sven suggested. It works now! the rule looks like this now: E=REWRITEBASE:/]. @serverliving.com your comments give me the answer, you should put them together in an answer so I can accept it and more people could take benefit of that. Apr 25, 2016 at 6:29

2 Answers 2

2

I think you don't require this ->RewriteRule . -[E=REWRITEBASE:/mysitefolder/]

since your DocumentRoot is already pointing to /var/www/mysitefolder/ . You can try commenting this rule or replace it with RewriteRule . - [E=REWRITEBASE:/]

Hope this helps.

1

You have to bind the domain with IP address.

<VirtualHost *:80>
    DocumentRoot /var/www/mysitefolder/
    ServerName example.com
    ServerAlias www.example.com
</VirtualHost>

instead of this use:

<VirtualHost example.com:80>
    DocumentRoot /var/www/mysitefolder/
    ServerName example.com
    ServerAlias www.example.com
</VirtualHost>

In place of * add the domain name.

3
  • Added that and now I get a 404 The requested URL /mysitefolder/index.php was not found on this server. Apr 25, 2016 at 5:33
  • error_log will give you more idea, What's the error in the log for that 404 error. Your first configuration looks correct to me. Also are you using apache 2.4 ?. Apr 25, 2016 at 5:38
  • @serverliving.com thank you, I updated my answer with that information. Still getting the error. Apr 25, 2016 at 5:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .