Apache rewrite URL not working in vhost.conf












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










share|improve this question



























    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










    share|improve this question

























      0












      0








      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










      share|improve this question













      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







      server apache2 php mod-rewrite






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 18 at 7:05









      GHOST

      269110




      269110






















          1 Answer
          1






          active

          oldest

          votes


















          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






          share|improve this answer























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











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1102754%2fapache-rewrite-url-not-working-in-vhost-conf%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          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






          share|improve this answer























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
















          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






          share|improve this answer























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














          1












          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






          share|improve this answer














          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







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 18 at 20:43

























          answered Dec 18 at 20:34









          s1mmel

          1,135516




          1,135516












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


















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
















          its work i think thz :)
          – GHOST
          Dec 19 at 4:03




          its work i think thz :)
          – GHOST
          Dec 19 at 4:03


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1102754%2fapache-rewrite-url-not-working-in-vhost-conf%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How did Captain America manage to do this?

          迪纳利

          南乌拉尔铁路局