Which htaccess code?

Discuss Search Engine Optimization in relation to Joomla! 3.x. This forum will also have discussions on SEF/SEO Joomla! 3.x extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
User avatar
ahdes
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Wed Jan 10, 2007 9:54 pm
Location: Istanbul
Contact:

Which htaccess code?

Post by ahdes » Sun Oct 14, 2018 2:04 pm

Hi.

How can I prevent accessed at the form of www.sitename.com/~folder/
What is the required htaccess code?

Thanks.

User avatar
CyrusXxX
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 236
Joined: Wed Oct 04, 2017 6:23 am
Location: Belgrade Serbia
Contact:

Re: Which htaccess code?

Post by CyrusXxX » Sun Oct 14, 2018 2:24 pm

So many options are available to you ahdes here are few:
1. Create htaccess rule and use redirect. Example:

Code: Select all

RedirectMatch 403 ^/folder/?$
This will prevent access to folder and put up 403 page, but not to files located inside.

2. Create htaccess in that folder and set deny to all rule. Example:

Code: Select all

Order Allow,Deny 
Deny from all 
3. If you want to secure it more maybe this also:

Code: Select all

<FilesMatch "\.(jpg|gif|png|php)$">
Order Deny,Allow
   Allow from all
</FilesMatch>
You can set file formats match and prevent usage of those files.
Also read this:
www.htaccess-guide.com
Joomla Serbian Latin Coordinator
https://volunteers.joomla.org/joomlers/ ... oran-nesic

Power is knowledge and knowledge is power.
https://regenesiscomputers.com

User avatar
ahdes
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Wed Jan 10, 2007 9:54 pm
Location: Istanbul
Contact:

Re: Which htaccess code?

Post by ahdes » Sun Oct 14, 2018 2:45 pm

Thank for answer.
But I do not understand my problem.
My site in this folder (~folder)
I want to block access to the site with "~ + site cpanel folder name"



CyrusXxX wrote:
Sun Oct 14, 2018 2:24 pm
So many options are available to you ahdes here are few:
1. Create htaccess rule and use redirect. Example:

Code: Select all

RedirectMatch 403 ^/folder/?$
This will prevent access to folder and put up 403 page, but not to files located inside.

2. Create htaccess in that folder and set deny to all rule. Example:

Code: Select all

Order Allow,Deny 
Deny from all 
3. If you want to secure it more maybe this also:

Code: Select all

<FilesMatch "\.(jpg|gif|png|php)$">
Order Deny,Allow
   Allow from all
</FilesMatch>
You can set file formats match and prevent usage of those files.
Also read this:
www.htaccess-guide.com

User avatar
CyrusXxX
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 236
Joined: Wed Oct 04, 2017 6:23 am
Location: Belgrade Serbia
Contact:

Re: Which htaccess code?

Post by CyrusXxX » Sun Oct 14, 2018 3:45 pm

ahdes wrote:
Sun Oct 14, 2018 2:45 pm
Thank for answer.
But I do not understand my problem.
My site in this folder (~folder)
I want to block access to the site with "~ + site cpanel folder name"
Sorry your question was poorly written.

If you want to block your site via cpanel visit your cpanel control panel and depending on what is available to you you will block it.

Still my answer/potential solution is the same make htaccess redirect or simply delete it.

Here is example for domain/subdomain/folder

Code: Select all

  RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www.)?mainwebsite.com$ [NC]
    RewriteCond %{REQUEST_URI} ^/google.com/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/something.net/(.*)$ 
    RewriteRule ^(.*)$ - [L,R=404]
    or:
    RewriteEngine On
        RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
        RewriteCond %{REQUEST_URI} ^/addonfolder/(.*)$
        RewriteRule ^(.*)$ - [L,R=404]
Joomla Serbian Latin Coordinator
https://volunteers.joomla.org/joomlers/ ... oran-nesic

Power is knowledge and knowledge is power.
https://regenesiscomputers.com

User avatar
ahdes
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Wed Jan 10, 2007 9:54 pm
Location: Istanbul
Contact:

Re: Which htaccess code?

Post by ahdes » Sat Oct 27, 2018 3:09 pm

Thank for answer.
for understand my problem, I add link.
True link: http://www.mebakademi.com/hakkimizda/ta ... imler.html
False link: http://www.mebakademi.com/~mebakade/hak ... imler.html

there is "~mebakade" in false link
CyrusXxX wrote:
Sun Oct 14, 2018 3:45 pm
ahdes wrote:
Sun Oct 14, 2018 2:45 pm
Thank for answer.
But I do not understand my problem.
My site in this folder (~folder)
I want to block access to the site with "~ + site cpanel folder name"
Sorry your question was poorly written.

If you want to block your site via cpanel visit your cpanel control panel and depending on what is available to you you will block it.

Still my answer/potential solution is the same make htaccess redirect or simply delete it.

Here is example for domain/subdomain/folder

Code: Select all

  RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www.)?mainwebsite.com$ [NC]
    RewriteCond %{REQUEST_URI} ^/google.com/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/something.net/(.*)$ 
    RewriteRule ^(.*)$ - [L,R=404]
    or:
    RewriteEngine On
        RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
        RewriteCond %{REQUEST_URI} ^/addonfolder/(.*)$
        RewriteRule ^(.*)$ - [L,R=404]

User avatar
CyrusXxX
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 236
Joined: Wed Oct 04, 2017 6:23 am
Location: Belgrade Serbia
Contact:

Re: Which htaccess code?

Post by CyrusXxX » Sat Oct 27, 2018 10:16 pm

Now I understand your issue ahdes.

Read this topic ahdes:
viewtopic.php?t=808095

You have to set-up a sub-domain or virtual host. For that ask your host.

Or move the Joomla files one folder up :
https://docs.joomla.org/Moving_the_site ... irectories or use backup solutions for that like for example Akeeba backup.

But before that disable url management component you are using on your site ( one which adds .html on the end of urls on your site) just in case if is messing with your site.
Joomla Serbian Latin Coordinator
https://volunteers.joomla.org/joomlers/ ... oran-nesic

Power is knowledge and knowledge is power.
https://regenesiscomputers.com

User avatar
ahdes
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Wed Jan 10, 2007 9:54 pm
Location: Istanbul
Contact:

Re: Which htaccess code?

Post by ahdes » Tue Oct 30, 2018 7:27 am

thank you very much for your support.
CyrusXxX wrote:
Sat Oct 27, 2018 10:16 pm
Now I understand your issue ahdes.

Read this topic ahdes:
viewtopic.php?t=808095

You have to set-up a sub-domain or virtual host. For that ask your host.

Or move the Joomla files one folder up :
https://docs.joomla.org/Moving_the_site ... irectories or use backup solutions for that like for example Akeeba backup.

But before that disable url management component you are using on your site ( one which adds .html on the end of urls on your site) just in case if is messing with your site.


Locked

Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 3.x”