remove directory slash url

spacresx

Community Advocate
Community Support
Messages
1,621
Reaction score
129
Points
63
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:

skillsbo

New Member
Messages
10
Reaction score
0
Points
1
any time you try to enter a directory on any website, Apache looks for any index file.
it could be index.php index.html even a index.htm file.
if there is no index file it normally shows a list of files that are there.
unless you have that feature disabled in htaccess.

There is ways to use htaccess to prevent showing any files.
but no way to hide the directories / slash as far as i know.
most people would not want their website accessed like that anyway.
remember if you can do it, than the rest of the world can to.

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?
 

skillsbo

New Member
Messages
10
Reaction score
0
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.
 

spacresx

Community Advocate
Community Support
Messages
1,621
Reaction score
129
Points
63
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.
 

skillsbo

New Member
Messages
10
Reaction score
0
Points
1
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.

Will do! Thank you for helping, learned a few new things today. :)
 
Top