Is it possible to write a redirect for a modified url string for a website ?

Discussion in 'Server Operation' started by showe1966, Dec 30, 2024.

  1. showe1966

    showe1966 Member

    Hi there,
    I have a website hosted using ispconfig3.2.9 and it currently has a set of urls in it with this format:-
    www.mysite.com/mysite_catalog (and then the rest of a series of html addresses which are nested in sub-directories below this to level)
    I need to modify this to:
    www.mysite.com/mysitecatalog (for all this series of html addresses within this same sub-directory).
    Can I do this by setting an apache directive for the website via the ispconfig3 control panel ?
    If so, what do i have to write ???
    Cheers for all your help in advance, guys and gals....
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    You can do this via the Apache directives field in ISPConfig, but even easier by using a .htaccess file in the wen folder to add the Apache rewrite rule.
     
    ahrasis likes this.
  3. showe1966

    showe1966 Member

    Hi there.
    I discovered I have actually set up some website redirects via the ispconfig control panel already in order to redirect http to https and xxx.mydomain.com and other variants to www.mydomain.com.
    This was achieved by:
    1. Log into the ispconfig control panel.
    2. Click on the "sites" icon in the top menu bar.
    3. The list of the website you are hosting is displayed in a list in the center window
    4. click on the link where it says "mysite.com" under the column "Domain" of the website you want to change.
    5. This opens a central panel entitled "Web Domain".
    6. Click on the tab at the top labelled "Redirect"
    7. There is a dropdown menu you can open in the box next to the label "SEO Redirect:"
    8. From in the dropdown menu , select "* =>www.domain.tld"
    9. Click on save.
    So, I was expecting to see something about this in my .htaccess file for that website, which is located at the default location as follows:-
    /var/www/clients/client1/web1/web/.htaccess
    However, there are no directives in this file. Looks like just some other security stuff:-
    **************************************
    ## Default .htaccess file
    <IfModule mod_headers.c>
    Header set X-XSS-Protection "1; mode=block"
    Header unset Pragma
    Header append Cache-Control "public"
    </IfModule>
    ***************************************
    So, I presume that the apache directives are being put into another file, which I imagine is either the "virtual host" config file or the httpd.conf file ?
    I would like to check these files and see where the "SEO Redirect" directives written in via the ispconfig control panel are being put.
    Also because I now need to add an additional new "301 redirect" directive which is going to redirect the address format of some pages on my website which have now changed to a new format.
    I believe that the new additional redirect statement should have the format:
    *********************************************
    # Check if mod_rewrite is loaded
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^/my_catalog$ /mycatalog [R=301,L]
    </IfModule>
    *********************************************
    So now, I wonder if you can tell me the following:-

    1. In terms of site responsiveness and security, what is the best place to put these apache directives, given that I have access to the whole computer ? Note: I have read that it is not ideal to use the .htaccess file for this, as it can be potentially insecure and also it slows down your website response.
    2. What should I put in the config file exactly and where is this config file likely to be located anyway ?
     
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Make listing of files in /etc/apache and it's subdirectories sorted by modification date. Then examine the most recently modified files.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    If you do not want to use .htaccess, then you can use the Apache directives field of the website, as I mentioned in post #2.

    You do not edit any config file manually, use the Apache directives field of the website.
     
    ahrasis likes this.
  6. showe1966

    showe1966 Member

    I found that the vhost configuration file of www.mydomain.com will be in the following location by default:-
    /etc/apache2/sites-available/mydomain.com.vhost

    It seems that this is where ispconfig automagically writes the apache directives to when you type them in via the ispconfig interface.
    This file appears pretty scary and long, and , seemingly has several sections in it which repeat for providing the different areas of functionality of the virtual host.
    I am gonna try adding my new needed rewrite directive into this file directly on my test server and I'll let you know how I get on.
    I guess I should really do this via the ispconfig interface as per what Till says, but, not sure how to do that either, so, i will try it the manual way :p
    What can possibly go wrong ? ha ha ha
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Very bad idea as your changes will get removed automatically. As I said, use the Apache directives field.

    Go to the website settings in ISPConfig, there you click on the options tab of the website. There you find the Apache directives field where you can add your rewrite rules.
     
    ahrasis likes this.

Share This Page