How to use htaccess
Posted by: Trond (---.43.213.193.static.cust.telenor.com)
Date: January 09, 2020 04:38PM

I have done a lot of searching for htaccess information. Searched the web, saw a few youtube videos and read a few posts on Reddit.

To the basics. I have a local computer working as a development server. I use wampserver on a standard pc. I have setup a development domain for its use like dev.webdomain.com. Each web then get a subfolder name under the main domain. Like dev.webdomain.com/customer/

During time I have had strange errors and struggeled with htaccess file, but never took the time to understand it. Thats something I'm currently doing something with, but have not yet found all the answers.

My dev server is "silent" meaning I dont tell anyone except from those I do work for. Still, and I knew it would happen some time, I've been noticing unwanted visits and I want it to stop.

First of all I want to block out visits to the root directory dev.webdomain.com as it contains a list of projects and a way to edit and create projects and virtual hosts.

I have done this in htaccess(deny from all and allow from my ip's), but it also blocks out the customer sites I'm working on. I found that I could edit the htaccess file in each customer site to open them again to outsite access(allow from all).

Is there a way to make the htaccess file in my root folder only apply to that folder?

Is there a smarter way to do this?

I'm including my two versions of htaccess here:

Root htaccess:

# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>



# END WordPress



AuthUserFile /dev/null

AuthGroupFile /dev/null

AuthName "WordPress Admin Access Control"

AuthType Basic

<LIMIT GET>

order deny,allow

deny from all

# whitelist tROND HJEMME IP address

#allow from xxx.xxx.xxx.xxx

# whitelist Kontorets IP address

allow from xxx.xxx.xxx.xxx

##whitelisted local ip's as I access the webserver by modifying my host file.

allow from 192.168.2.

allow from 192.168.1.

</LIMIT>

Opened customer project:

# BEGIN WordPress

# The directives (lines) between \BEGIN WordPress` and `END WordPress` are`

# dynamically generated, and should only be modified via WordPress filters.

# Any changes to the directives between these markers will be overwritten.

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /customer/

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /customer/index.php [L]

</IfModule>



# END WordPress

allow from all

php_value upload_max_filesize 64M

php_value post_max_size 64M

php_value max_execution_time 300

php_value max_input_time 300

Options: ReplyQuote
Re: How to use htaccess
Posted by: RiggsFolly (Moderator)
Date: January 09, 2020 05:28PM

Hi

Simple answer is Virtual Hosts. Specially as you are using WordPress you shoudl already be using Virtual Hosts for each of your sites.

See The Need for Virtaul Hosts

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.2.0 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.16>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: How to use htaccess
Posted by: Trond (---.81-167-166.customer.lyse.net)
Date: January 09, 2020 09:38PM

Virtual Hosts is for only working on local computer(if I have understood it right). I access these webs both from my office and at home. I do also let the owner og the new website participate and follow the process. Then your answer does not fit my question.

Options: ReplyQuote
Re: How to use htaccess
Posted by: Otomatic (Moderator)
Date: January 10, 2020 10:59AM

Hi,

> Virtual Hosts is for only working on local computer(if I have understood it right).
NO.

All hosting providers use VirtualHost. You don't notice it because the VirtualHost exists before you upload your site to it and was created by the hosting provider.

VirtualHosts are essential for CMS and WEB and WordPress applications, among others, will work badly, if not installed in a VirtualHost; moreover, the VirtualHost must exist BEFORE installing Wordpress.

>Then your answer does not fit my question.
This forum is not intended to debug PHP scripts, MySQL queries or .htaccess files.
See : [httpd.apache.org]
or WordPress documentation

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.0 32 bit - Apache 2.4.41 - PHP 7.4.3/7.3.15/..../5.6.40 - MySQL 5.7.29 - MariaDB 10.4.12
Wampserver 3.2.0 64 bit - Apache 2.4.41 - PHP 7.4.3/7.3.15/..../5.6.40 - MySQL 5.7.29/8.0.19 - MariaDB 10.4.12
PhPMyadmin 5.0.1 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote


Sorry, only registered users may post in this forum.