0

this my vhost.conf

<VirtualHost *:80>
<files xmlrpc.php>
      order allow,deny
      deny from all
    </files>
    ServerName www.myserver.com
    ServerAlias myserver.com

    DocumentRoot /var/www/vhosts/www.myserver.com
    <Directory /var/www/vhosts/www.myserver.com>
   Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
# AllowOverride None
        #Order Allow,Deny
        #Allow from All
        #Deny from 124.43.19.230

        <IfModule mod_rewrite.c>
          RewriteEngine On
          RewriteBase /
          RewriteRule ^index\.php$ - [L]
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule . /index.php [L]

# Restrict access to PHP files from plugin and theme directories
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/directory/to/exclude/
RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L]
RewriteCond %{REQUEST_URI} !^/wp-content/themes/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/themes/directory/to/exclude/
RewriteRule wp-content/themes/(.*\.php)$ - [R=404,L]
        </IfModule>
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/directory/to/exclude/
RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L]
RewriteCond %{REQUEST_URI} !^/wp-content/themes/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/themes/directory/to/exclude/
RewriteRule wp-content/themes/(.*\.php)$ - [R=404,L]
</Directory>
</VirtualHost>

when in browser i type www.myserver.com its go to my root directory and get index.php

but when i type myserver.com its go to default Apache web page (index.html) loading

so i add this line for rewrite

</VirtualHost>
 <VirtualHost *:80>
      ServerName myswever.com
      ServerAlias *.myswever.com
      Redirect permanent / https://www.myswever.com/
    </VirtualHost>

but its not working its a word-press site how to rewire url

when some type myswever.com its should load www.myswever.com

1 Answer 1

1

Is it maybe just a typo?

      ServerName myswever.com
      ServerAlias *.myswever.com
      Redirect permanent / https://www.myswever.com/

myswever?

Otherwise check if there are other configs active, with

a2ensite

deactivate with

a2dissite

Also check if there is another config creating this under

/etc/apache2/*.conf
/etc/apache2/sites-enabled/*

BTW your vhost.conf is for Port 80 which is plain HTTP, your redirect goes to HTTPS, Port 443. If you don't avtivate mod_ssl and add/extend the vhost config for port 443, the https redirect won't work.

Your standard apache page suggests you still have an active default config, which you can delete, it should be in the folder /etc/apache2/sites-available/* and if it is active there will be a symlink to /etc/apache2/sites-enabled/* for this config. Both commands above show all active or inactive configs and they will simply delete the symlink for this config under /etc/apache2/sites-enabled/*

Hope that helps, s1mmel

1
  • its work i think thz :)
    – GHOST
    Dec 19, 2018 at 4:03

You must log in to answer this question.

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