remove directory slash url

Discussion in 'Off Topic' started by skillsbo, Dec 18, 2019.

  1. skillsbo

    skillsbo New Member

    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
  2. spacresx

    spacresx Active Member

    Messages:
    614
    Likes Received:
    34
    Trophy Points:
    28
    any time you try to enter a directory on any website,
    Apache looks for any index files.
    They could be index.php index.html even a index.htm file.
    if there is no index file it normally shows a list of files instead.
    unless you have that feature disabled in htaccess.

    There is ways to use htaccess to prevent showing any files.

    you can also search google on ways you can do that though.
    i did find this on stack overflow but I never tried it so i dont
    know if it works, but they describe similar to what you
    are trying to do.
     
    Last edited: Dec 19, 2019
  3. skillsbo

    skillsbo New Member

    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Thank you for your reply, I wasnt sure this was possible.

    So how do websites have like : http://example.com/something
    Is the "something" always a file and they remove their extensions?
     
  4. skillsbo

    skillsbo New Member

    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    The link you put on your comment has this in one of the comments:

    Code:
    Options +FollowSymLinks -MultiViews -Indexes
    
    DirectorySlash Off
    
    RewriteEngine on
    
    RewriteRule ^projects$ /projects/index.php [L,E=LOOP:1]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^\.]+)$ $1.php [NC,L]
    Changed the directory and file name and seems like it works.
    But i'm still curious, how do most of the websites have this structured? Is the last url part the file with no extension or directory with no dash or something else.
     
  5. spacresx

    spacresx Active Member

    Messages:
    614
    Likes Received:
    34
    Trophy Points:
    28
    Generally most of the sites i visit has a simple link like http://example.com
    they dont usually use sub folders like http://example.com/wordpress
    or things like that in their links.
    most sites are normally structured like this:
    public_html
    public_html\sub folder\
    public_html\sub folder\sub folder\
    with public_html being the root folder thats seen with http://example.com
    you can control the page thats seen using htaccess file using the standard:

    DirectoryIndex /index.php

    using that dont show the index.php when you type http://example.com
    but will still load the index.php file.
    same way in theory you could probably force a sub folders index page to load to.
    using http://example.com would load the public_html\sub folder\index.php too
    maybe experiment with that to get what you want.
     
  6. skillsbo

    skillsbo New Member

    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Will do! Thank you for helping, learned a few new things today. :)
     

Share This Page