Creating apache alias without access to .conf file - php

I have a PHP application that is written in Zend Framework. The document root is appdir/public. In appdir I also have a directory called admin that hosts a wordpress website. I would like to be able to map an alias to appdir/admin so that the wordpress website can be reached at website.com/admin. Unfortunately, I do not have access to my apache conf files through my hosting provider. Is it possible to map an alias without access to that? I was thinking in the .htaccess file but after extensive googling, that doesn't look possible either. All help/suggestions are appreciated. Thanks!
I have tried contacting my hosting provider and getting access to the apache conf file, but they wouldn't let me. (SiteGround)
I have tried using the .htaccess file.
Edit: Apache 2.4

Currently you can' use .htaccess to move current directory above document root.

Related

Symfony4 web.config for IIS on azure

I've deployed a symfony4 project on Azure, it uses IIS so .htaccess doesn't work. I've set the root folder on Azure app settings to "site\wwwroot\testproject\public" that folder contains index.php. I've tryed differents web.config without results.
If I open the app url it says: "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
but if I open the url appending /index.php it shows the content. I need a rewrite rule like symfony/apache-pack gives for apache but for IIS.
Thanks a lit
There is an extensive article on learn.microsoft.com on converting .htaccess to web.config: https://learn.microsoft.com/en-us/iis/application-frameworks/install-and-configure-php-applications-on-iis/translate-htaccess-content-to-iis-webconfig
I won't paste the contents here since it is very extensive and I don't use Windows and you may have custom .htaccess rules.
I suggest you to identify all .htaccess config files on your install and convert them.

Is there any way to hide wp-config.php inside Google App Engine?

Just that.
I mean.
I'm a bit noob in GAE. I have a WP web running inside it and I want to protect it a bit. If you are using, for example, Apache, you can put this thing inside the .htaccess file:
<Files wp-config.php>
Order Allow,Deny
Deny from all
</Files>
and if you try to access to it (directly, www.foo.bar/wp-config.php) you are going to obtain a 403 forbidden error, but I can't find anything similar to get the same results using the app.yaml file.
Is GAE managing differently this kind of attack? Do we have any other option, apart of to change the location of the file?
Thanks.
According to the WordPress docs, you can place the wp-config.php file one directory above the equivalent of root or public_html and WordPress core will be able to find it. See https://codex.wordpress.org/Editing_wp-config.php
If you have a similar directory structure in GAE (I'm not a user of GAE), try that.
But there are questions as to if this is beneficial: https://wordpress.stackexchange.com/questions/58391/is-moving-wp-config-outside-the-web-root-really-beneficial

zend framework 2 project in server doesn't work

Working with zf2, we have configured the project successfully in local env, we deployed the same code to server, but there..only the IndexController action is working.
like www.project.com/public/ works,
but when I access other modules like
www.project.com/public/country doesn't work.
This means the mod_rewrite rules to rewrite all requests to your index.php file are not being used. Generally this means either:
The .htaccess file was not uploaded (check the public folder on the server to see if it's there)
The .htaccess file is being ignored (check AllowOverride for the vhost on the live server)
Also, really public/ should not appear in your URLs. Unless you are using shared hosting (where this can be tricky), you want to point your vhost's document root at the public folder.
In a proper Zend setup an error should come from Zend. When you get an error like this, returned from Apache, your apache configuration is not working. Your Zend application isn't even considered, i.e. the index.php in your public folder.
It's a save guess that your [public/].htaccess isn't used. Check your apache web configuration. Most likely you're missing the AllowOverride All statement which is usually inside the <Directory> statement.
And as mentioned by Tim you really should not have public/ in your path to begin with.

.htaccess file won't respond on localhost:63342 in PhpStorm

I'm using the IDE PhpStorm 7.1.4 and trying to make an .htaccess file to stop users from going into a specific directory.
My folder structure is like this:
I want to make it so that users can't go in the /app folder or any folders inside that folder. For this, I've figured out that I can use this piece of code inside .htaccess:
Options -Indexes
I'm using the PHP web server from PHPStorm itself (which goes to localhost:63342/projectname/folderinproject/etc/etc/).
Problems
When directing to the page to the /app folder, I get an 404 error,
saying the index file doesn't exist.
When I have made an index.php file inside the /app folder, and I am redirecting to the /app folder, it just loading up the index.php.
When doing this with just a normal HTML project and opening the index.html via my windows explorer, the same problem occurs
Question
How can I make it so that my project would actually respond on the .htaccess file and wont allow me or other users to go into the /app folder?
EDIT
I figured out that when I copy all my files from my project to the c:\xampp\htdocs\ folder and turn on my Apache server inside of XAMPP, the .htaccess file is working whenever I open it via my regular browser (without selecting index.php in PhpStorm and choosing Open in browser...).
Is there any way I can do this same thing in PhpStorm without moving all the files?
If you are using the default configured web server, you are actually using PHP's new web server feature, which doesn't listen to .htaccess files. Only Apache listens to .htaccess files.
If you are wanting to test this functionality, you can either setup a VM running Linux and test, or setup WAMP on your system and run from there.
EDIT 1
Ok, can you add a little more detail about the exact problem? When you access localhost/app/ it is displaying the index.php file, instead of the 404. Does the application work entirely through the index.php file? If so, is the index.php file in the app or public?
EDIT 2
Ok, here's what you need to do. Place an .htaccess file in the root of your app directory. Clear the contents of this .htaccess and place the line DENY from ALL. You can keep the .htaccess file in the root of the project.
EDIT 3
PHPStorm is going to use the PHP Engine's web server. If you add the XAMPP location as a deployment path, it's fairly quick to deploy to. You can even setup PHPStorm to automatically deploy files to the XAMPP location on save. Here's the walk-through on the JetBrains site JetBrains Config.
The .htaccess plugins are mainly for editing and formating, not for modifying PHP Engine's server environment.
Using mod_alias is even easier:
Redirect 301 /app /new_directory
But if you have rewrite rules in your htaccess file already, then you need to stick with using mod_rewrite:
RewriteRule ^app/(.*)$ /new_directory/$1 [L,R=301]

Owncloud not available after installation on Ubuntu server 14.04

With the goal to install owncloud (version 6.0.3-0) on my ubuntu server (14.04), I followed this guideline:
http://doc.owncloud.org/server/6.0/admin_manual/installation/installation_source.html
After having this completed, the /var/www/owncloud folder exists with the following content:
3rdparty core index.html occ robots.txt themes apps cron.php index.php ocs search version.php config data l10n public.php settings console.php db_structure.xml lib remote.php status.php
Visiting
http://localhost
results in a site like this: https://assets.digitalocean.com/articles/lamp_1404/default_apache.png indicating, that the apache-server works.
Visiting
http://localhost/owncloud
leads to server error 404: "Not Found".
Meanwhile, I tried the installation (owncloud 6.0.3-0) on my laptop (Ubuntu 13.10) to compare results. Skipping the above guidelines, just installing owncloud using the package-manager works out of the box, while the content of /var/www/owncloud results only in config data
Since it works on my laptop, I have the suspect, that I screwed up some configuration on my ubuntu server. Even so, reinstalling apache2 (including purge) did not help.
Do you have any ideas, where to start over?
This is because Apache 2.4's default web root is /var/www/html as opposed to /var/www. ownCloud's default installation ends up in /var/www/owncloud, which is outside of the web root.
I first solved this by creating a symbolic link at /var/www/html/owncloud, but I found it cleaner to simply change Apache's document root to /var/www/owncloud. If you want to preserve the owncloud subdirectory, you can point it to /var/www and get rid of /var/www/html and its contents.
Edit /etc/apache2/sites-enabled/000-default.conf (and/or the appropriate configuration for the SSL site in the same location, depending on your setup) to point DocumentRoot to /var/www or /var/www/owncloud, whichever works for you.
I just figured this out myself, so it may warrant further configuration changes. I will update this post if/when I figure out more tweaks need to be made, but it seems to be working for me, anyway.
Also this has nothing to do with programming and really belongs on superuser.com or perhaps serverfault.com.
This would be more appropriate as a comment as I'm completely clueless as to the solution, but the strange system of SO doesn't allow me to post comments. I have an idea that may not help but just want to confirm that it's not the problem.
Have you tried the following URL?
http://localhost/owncloud/index.html
The first thing that came to mind is that there is a problem with your Default Document settings.
If the above works, you can fix it so you don't have to define the HTML file in the URL by creating a .htaccess file in your server root directory with the contents being:
DirectoryIndex index.php index.html index.htm default.html default.htm home.html
Hope this helps.

Categories