Apache .htaccess -> Nginx config - apache

I am just started looking into using Nginx over Apache into my own LAMP stack. But I use a number of frameworks (CakePHP) which use .htaccess files.
What I don't understand is if I need to convert theses files into something else?

.htaccess will not be useful to nginx. You need to convert them to /etc/nginx/nginx.conf like files.
Here is a start for pretty URLs with CakePHP (official doc):
http://book.cakephp.org/2.0/en/installation/url-rewriting.html#pretty-urls-on-nginx
Note: generally, you'll add a yoursite.conf file in /etc/nginx/sites-enabled/

Related

Does Apache create .htaccess file on startup

Working with Docker and a PHP application. Something (assuming Apache) is creating the following .htaccess file in webroot on container start up.
/var/www/html# cat .htaccess
Deny from all
I delete the .htaccess file and my application works properly. Then shows up again when I start the container. This is a basic Debian Stretch / Apache / PHP 7 image with my PHP code added to it.
Looking for reason or module that is doing this.
Edit: The Dockerfile https://pastebin.com/VDTFYJ0X
Apache is not automatically creating .htaccess files.
I highly assume that your problems is caused by docker.
Try checking your Dockerfile.
The program creating .htaccess file is Composer. Note this issue:
https://github.com/composer/composer/issues/5816
Best to set COMPOSER_HOME to something other than the web root.

Run cakephp app in apache alias

I'm trying to deploy a cakephp 3.1 app in a apache 2.4 powered server. My boss would like to place the app in a directory different of server's documentroot (DocumentRoot "/var/www/html" in my httpd.conf file), since multiple webapps will be served by this server.
Instead of virtualhosts, he would like to use aliases (host/app1, host/app2 etc). So I'm trying to configure it this way. I put an alias to my cake app (Alias "/scqa" "/opt/scqa/webroot" in my httpd.conf file) and wrote a RewriteBase (RewriteBase /scqa) to both cake's .htaccess files, but every absolute link present in my app is still pointing to apache's documentroot. In this particular case, it means my css and a big pile of not properly built links are 404ing. Is there some way I can fix it in apache configuration?
I know 2 other ways to fix it: Fix the links with cake syntax (will take me a week) or use virtualhosts. But is it possible to fix it and keep using apache alias?
Thanks in advance.
(The production env uses centos 7 64bits, just in case)
If I understood well, you are using aliases in your .htaccess files.
You should put the Alias in your server config file, because it won't work otherwise.
Syntax: Alias [URL-path] file-path|directory-path
Context: server config, virtual host, directory
From https://httpd.apache.org/docs/current/mod/mod_alias.html

Will .htaccess files still work if Nginx is running (along with Apache)?

Will .htaccess files still work if Nginx is running (along with Apache), or do I need to disable Nginx for them to work?
Thanks!
.htaccess is an Apache config file. Nginx doesn't use it (file is ignored and treated like any other), and Apache config rules don't apply to Nginx.

Is there a way for Apache to silently ignore unrecognized .htaccess directives?

I'm in the unfortunate position of having an Apache staging server combined with a Zeus web server. (Not my choice).
I'd like to be able to include a Zeus-specific directive in the .htaccess file (e.g. ContentCompressionEnabled) and, if possible, include the Apache equivalent (AddOutputFilterByType DEFLATE) in the same file too.
Is there a way of doing this which doesn't involve separate .htaccess files for Zeus and Apache?
Only in 2.4, where there is an Nonfatal option to AllowOverride.
If I understood correctly, you can use httpd.conf file do this configuration for all requests. .htaccess file configurations effect only requests to where the file located.
You could put any Apache only directives into either Apache's main httpd.conf file, or the sites vhost config file - along with AllowOverride None.
This would mean that Apache would get all it's config info from there and ignore any .htaccess files completely.
You could then place anything you wanted in the .htaccess files, including all the Zeus config you need - and Zeus would be configured only from there - thus separating the two configs.

From where to start for URL rewrite in nginx?

I am new to nginx, and i would like to know from where I can start URL rewrite in nginx,
I know with apache we can have .htaccess file. but for whenever I have search for ngingx i just get the rules and syntax and all that. But i would like to know in which file I have to write these rules just like .htaccess file for apache.
nginx doesn't have an equivalent to .htaccess files, you need to put the rewrite rules in the server config.