Enable open directory (folder browsing) .htaccess and httpd.conf - wordpress

I am running WordPress on an AWS instance. I would like to open up a single directory on my server to allow folder browsing.
I have tried adding an .htaccess file to folder with the line
Options +Indexes
I have also tried modifying the httpd.conf file in /opt/bitnami/apache2/conf and adding
<Directory "/publicFolder">
Options +Indexes
AllowOverride All
Require all granted
order allow,deny
Allow from all
</Directory>
I have tried various combinations of the above options, but nothing seems to work. I have made sure to reboot the AWS instance after updating httpd.conf.
When I try to access the folder, I get a default WordPress page with the message "OOPS! THAT PAGE CAN’T BE FOUND." It is probably a simple mistake, but this is all new to me.
Thanks!

Directory is used for absolute file system paths. Make sure you speficy the whole path instead of just the relative path from documentroot.
Extra Note: Don't mix 2.2 and 2.4 directives. Remove Order/Allow directives.

Related

Hide WP-includes, and WP-content/uploads from WordPress

I am using WordPress, I have to hide WP-includes, and WP-content/uploads from WordPress. I have tried to add the below code in htaccess
Options -Indexes
Also, I have referred to this link but still, it's not working for me.
The below link is working
http://localhost:8080/wordpress/wp-includes/
but if I add then I can see all the files. Same for the upload folder
http://localhost:8080/wordpress/wp-includes/assets
http://localhost:8080/wordpress/wp-content/uploads/2022/01
Note-localhost is just an example
Where does the .htaccess file exist on the server? Which path?
Are you sure your web server is processing this file? Are you indeed running Apache?
As long as you have a file named .htaccess (no spaces), and it's placed in your root HTML folder, or within both wp-includes and wp-content folders, and somewhere within the file on its own line, you have Options -indexes, this should be respected for all subfolders and turn off auto-indexing. Can you share the entire contents of this file, perhaps you have placed this line somewhere it's not being read.
After some research, I have created a .htaccess file in the wp-content/uploads and added the below code. And it's started working
# Kill PHP Execution
<Files ~ ".ph(?:p[345]?|t|tml)$">
deny from all
</Files>

Setting up an Apache VirtualHost for Symfony

Admittedly I am utterly new to Symfony and I am irritated.
I am using the docu here: [0]. After setting everything up with "symfony/apache-pack" I get the ".htaccess" file with heaps of stuff in the "/public" directory. Now I wanted to be smart and moved all the rewrite rules to a proper VirtualHost and deleted the "htaccess" file. BANG, the required script files are not being loaded from the vendor directory and not style appear on the website. After killing all rewrite rules from the VirtualHost we website is up and running again.
Because of this sentence "A performance improvement can be achieved by moving the rewrite rules from the .htaccess file into the VirtualHost block of your Apache configuration and then changing AllowOverride All to AllowOverride None in your VirtualHost block." I am confused now since it suggests that I imperatively need rewrite rules for Symfony.
Note that I changed to AllowOverride None.
Can anyone shed some light onto this. I somehow feel that I am doing something dead wrong.
[0] https://symfony.com/doc/current/setup/web_server_configuration.html#web-server-apache-mod-php

Expires headers on an Amazon EC2 with Bitnami Wordpress

I'm working with a client who has a Wordpress installation (via Bitnami) set up on an Amazon EC2. I didn't put this together, and for background I am a Front-end Developer who is used to cPanel and has limited knowledge for the command line.
I'm trying to modify the expires headers to improve the speed of the client's site. Following this tutorial (http://www.theitbaby.com/wordpress/2013/10/14/optimizing-bitnami-for-pagespeed-insights-and-gtmetrix/) I was looking for the htaccess.conf file in my opt/bitnami/apps/wordpress/conf/ folder, however none existed. Do I make my changes in the httpd-app.conf file?
Alternatively I saw a few other resources out there with a line to include the htaccess.conf file added to httpd-app.conf - something like
Include /opt/bitnami/apps/wordpress/conf/htaccess.conf
Do I add this to the httpd-app.conf file and then create htaccess.conf and work there? Sorry for the confusion, just looking for some direction as I try to do my typical performance boost work.
So the option what you are describing: creating and htaccess.conf file and then adding it as an Include statement in the httpd-app.conf file under /opt/bitnami/apps/wordpress/conf/ is correct.
Make sure your Include statement is within the Directory directive and in the htaccess.conf file you don't need to have the Directory directive:
<Directory "/opt/bitnami/apps/wordpress/htdocs">
...
Include /opt/bitnami/apps/wordpress/conf/htaccess.conf
...
</Directory>
You can also add the pagespeed configs directly to the http-app.conf file if you'd like to inside the Directory directive too.
There's another option, but not necessarily popular if you have access to the main apache configuration files. You can create a .htaccess file under /opt/bitnami/apps/wordpress/htdocs and put your pagespeed statements there. In this care you need the following statement preconfigured by the sysadmin in the http-app.conf file.
<Directory "/opt/bitnami/apps/wordpress/htdocs">
...
AllowOverride All
...
</Directory>
You can read more about .htaccess here: http://httpd.apache.org/docs/current/howto/htaccess.html
Hope this helps.

Wordpress Noob: Forbidden You don't have permission to access / on this server. (using Mac)

So I followed this tutorial to set up my wordpress project on my local: http://jason.pureconcepts.net/2012/10/install-apache-php-mysql-mac-os-x/
However, it is giving me a
Forbidden You don't have permission to access / on this server.
error. I even tried changing the permissions of my project to 777, but nothing works. I should have Apache, MySQL, and PHP all running now. This is my /etc/apache2/extra/httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "/Users/emai/Documents/wordpress_projects/ahrf"
ServerName ahrf.local
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
<Directory "/Users/emai/Documents/wordpress_projects/ahrf">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And my /etc/hosts has this line 127.0.0.1 ahrf.local added. So it looks like my apache config + hosts file are configured properly. I even tried adding the default _www apache user to the staff group on my mac.
Does anyone know how to fix this?
While Macs are immensely easy and dumbed down compared to Linux and Unix Apple has added a ton more overhead in terms of trying to configure one as a server like you would normally configure a Unix or Linux system. They're running their own custom systems like Rendezvous, so there's a little more to configure and troubleshoot. That being said, here are a few things:
You should be able to connect to the system with the IP address and see the website. If you're not running a DNS server then the system will not publish the ahrf.local name. You would need to edit the hosts file of any systems trying to connect using that name. So on computer 2 you would edit the hosts file to see ahrf.local as 192.168.x.x (with the proper ip address for the web server of course).
If you install BIND you will need to make all of the other local machines check the DNS server first to see if the system exists.
Change permissions recursively in the folder to 755. You should never allow 777 because this allows "everybody" write access on the box. Wordpress has a ton of holes which can be found online by searching "Wordpress Hacked."
On Macs there's an issue with using the .local domain. .local is reserved for Rendezvous. While it will share files with this naming convention it's not really a published "domain name" and it will conflict with rendezvous if you're trying to use it in DNS.
Make sure (if you have firewall enabled under security) in the firewall you're allowing connections over port 80.
There is a web sharing option under newer versions of Mac OS. In my experience a lot of the systems that are in place in the GUI actually overwrite some of the command line additions. You'll need to either use the GUI exclusively or use the command line exclusively and then try to hunt down any issues in the GUI preventing the system from loading the page.
You don't need to run Apache as any other names or in any other groups other than the default as it only requires read and execute access to show the contents. The folders and files should have the permissions set for the user you're using to create the files. You don't want to make Apache own the files or you'll run into problems updating the system. Any folders where a user might upload a file like an image will need other permissions, but the main folder does not. Wordpress configures these settings on install.
If you want to run your Mac as a "production server" Apple has a "server" you can get "server" app from the app store that's basically another GUI interface for all of the stuff that normally comes available to Unix and Linux as installation options. It's cheap. This will allow you to run your own DNS server (and it's a little easier interface than editing BIND).
Also try pulling the directory declaration out of the VirtualHost. In all of the documentation examples they are separate.
<Directory "/Users/emai/Documents/wordpress_projects/ahrf">
Options -FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
DocumentRoot "/Users/emai/Documents/wordpress_projects/ahrf"
ServerName ahrf.home
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
Also remember after making changes to the .conf files you need to restart Apache. With .htaccess you do not have to restart after each change.
I know this is kind of old. But I followed same tutorial with my Mac machine to enable development with apache2 and faced the same situation.
To solve it I have added following line into my virtual host's directory. After that when I accessed a directory, apache didn't gave me a forbidden error.
Options Indexes FollowSymLinks MultiViews
After adding above line my virtual host configuration look like this.
<Directory "/Users/uiroshan/development/php">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Also please see the relevant section in apache documentation.
http://httpd.apache.org/docs/current/mod/core.html#options
Indexes
If a URL which maps to a directory is requested, and there is no DirectoryIndex (e.g., index.html) in that directory, then mod_autoindex will return a formatted listing of the directory.
Also enable the "Fancy directory listings" configuration file from your httpd.conf file.
Include /private/etc/apache2/extra/httpd-autoindex.conf
Hope this helps.
Easiest Solution I found was to symlink.
By default DocumentRoot is in /Library/WebServer/Documents
cd /Library/WebServer/
sudo mv Documents Documents-old
sudo ln -s <sourcedir> ./Documents
Dont mess up with OSX Apache config and break your head. Not worth it!

WAMP + directory alias + Drupal clean URLs

I have WAMP installed on my pc where I would like to run Drupal 6.
When I'm installing Drupal, I get the option to activate Clean URLs.
First I put my Drupal install in the www folder and I could choose to enable the clean URLs, but for backup reasons I moved it outside the www folder and created an alias the would point to the folder.
When I installed Drupal again, I couldn't choose to enable clean URLs anymore; the option was grayed out.
I would like to know why this happens; it seems some Apache module or PHP extension isn't available outside the www folder.
Just to be sure, I also tried an XAMPP install and created an alias with the some code lines as in the WAMP server but that worked, for some reason. The Apache version in WAMP isn't the same as the XAMPP install but I don't really think that is relevant.
I believe it's an config error in WAMP but I can't find out what.
Clean URLs doesn't work in the directory you copied Drupal because for that directory the directive AllowOverride is not set to All.
Drupal requires that every directives found in .htaccess files are enabled, in order to enable clean URLs; the directive AllowOverride, when set to All, allows to use all the directives that a .htaccess can contain.
The reason that in one case you can select the the option to enable the clean URLs, and in the other case is not selectable, is that Drupal, during its installation verifies the server is set to work with clean URLs, and change the form field to read-only if the server cannot support such feature.
To notice that the .htaccess file provided from Drupal can possibly need to be edited, in order to enable the clean URLs, as reported in the following comments, found inside the .htaccess file.
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /

Resources