I am trying to setup our blog, but cannot crack the right configuration...
The folder structure is:
var/www/domain
| - website
| - webapp
| - blog
Apache Config:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin admin#example.com
# -------------------------------------
# ------ Web Stuff ------
# -------------------------------------
# Website
DocumentRoot /var/www/example.com/production/website/code/wwwroot
<Directory "/var/www/example.com/production/website/code/wwwroot">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
# Webapp
Alias /pages /var/www/example.com/production/webapp
<Directory "/var/www/example.com/production/webapp">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
# Blog
Alias /blog /var/www/example.com/production/blog
<Directory "/var/www/example.com/production/blog">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php index.html
CustomLog ${APACHE_LOG_DIR}/domain_production_access.log combined
ErrorLog ${APACHE_LOG_DIR}/domain_production_error.log
LogLevel warn
# -------------------------------------
# -------------------------------------
# Catch any requests for example.com and redirect them to www.example.com
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) https://www.example.com/$1 [NC,R=301,L]
# Catch any http requests (except for status check and those that originated from
# this server) and redirect them to https
RewriteEngine On
RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/api/aws/check https://%{SERVER_NAME}%{REQUEST_URI} [NC,R=301,L]
# Django web service - all URLs beginning with /api
WSGIDaemonProcess www.example.com processes=8 threads=1 display-name=%{GROUP}
... FOLLOWED BY A LOT OF SETTINGS FOR API ...
<LocationMatch "\.(jpg|css|gif|pdf|ico)$">
SetHandler None
</LocationMatch>
# Zip output
AddOutputFilterByType DEFLATE text/css text/html application/x-javascript application/javascript application/json
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
I have installed WordPress in blog directory and connected to database. But when I try to open https://www.example.com/blog I see the content but no styling (all assets coming from non-https address).
I couldn't access wp-admin, so I manually changed the urls in database to https, still cannot see any assets on blog page, and when trying to access wp-admin I get redirection loop.
Installing https plugin solved it. there were 2 separate problems:
1) infinite loop
2) assets being served from http
The plugin solved both, the first problem solved by adding .htaccess to the root (which I tried milion times, but apparently I must have made some mistake in the rewrite rules).
But that doesn't solve the issue with assets (I know, I tried/tested). That means this pugin has to do some magic in php as well, which by my logic is a pretty big issue in the wordpress itself...
Just as a reference, this is how the .htaccess looks like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
Related
currently i want to setup 2 different Wordpress project on my AWS Linux 2. but i still want to use a same domain. but i stuck.
1st Wordpress project use domain http://domainname.com
2nd wordpress project use domain http://domainname.com/second
what i have done is like this
1st Wordpress project
i set the .htaccess with this.. this setting is avoid 404 page when access http://domainname.com/second
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/second/.*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./ /index.php [L]
</IfModule>
i also create a file "domainname.conf" on folder "/etc/httpd/conf.d/" with this setting
<VirtualHost *:80>
ServerName domainname.com
ServerAdmin email#gmail.com
DocumentRoot "/var/php_apps/domainname"
<Directory "/var/php_apps/domainname">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
ErrorLog /var/log/apache2/bar.error.log
LogLevel warn
CustomLog /var/log/apache2/bar.access.log combined
</VirtualHost>
this setting can load the page corretly. but i still can't display the 2nd wordpress project.. here is my setting
2nd Wordpress project
i set the .htaccess file with this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
i create a file "second.conf" on folder "/etc/httpd/conf.d/" with this setting
<VirtualHost *:80>
ServerName domainname.com/second
ServerAdmin email#gmail.com
DocumentRoot "/var/php_apps/second"
<Directory "/var/php_apps/second">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
ErrorLog /var/log/apache2/bar.error.log
LogLevel warn
CustomLog /var/log/apache2/bar.access.log combined
</VirtualHost>
but the 2nd wordpress project can't load the page when access domain http://domainname.com/second
error display
Not Found
The requested URL was not found on this server.
how do i able load the page from 2nd wordpress project when access domain http://domainname.com/second ?
please help.
I need some help with configuring Symfony on apache2 web server.
My current project category structure is:
var/www/domain.com/public_html
Inside public_html is where my Symfony application is located.
I am stuck at figuring our what I am doing wrong in my either .htaccess or /etc/apache2/sites-available/domain.com.conf files.
I am using symfony/apache-pack. My .htaccess files live inside /public folder as per documentation. Here it is:
DirectoryIndex index.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
RewriteRule .* - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 307 ^/$ /index.php/
</IfModule>
</IfModule>
And here is my /etc/apache2/sites-available/domain.com.conf
<VirtualHost *:80>
ServerAdmin someemail#example.com
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/mydomain.com/public_html/public
<Directory /var/www/mydomain.com/public_html/public>
AllowOverride All
Order allow,deny
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
I also read this and updated 000-default.conf as follows:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerAlias www.mydomain.com
DocumentRoot /var/www/mydomain.com/public_html/public
<Directory /var/www/domain.com/public_html/public>
Options FollowSymlinks MultiViews
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml >
</IfModule>
</VirtualHost>
For the moment I am still seeing symfony project folder structure.
I tried:
inside .htaccess changing DirectoryIndex to /public/index.php
inside .conf file changin DocumentRoot to /va/www/domain.com/public_html/public
tried clearing cache
SO far nothings seems to help.
Would be extremely helpful for any advice.
I see that you are editing vhost which begins with
<VirtualHost *:80>......
That mean your website should be reachable by 80 port or in other words by http protocol. But! If in reality you are accessing your website by https protocol then make sure you are editing right Apache2 .conf file.
If the website is reachable by https protocol (especially if you use LetEncrypt), then try locating /etc/apache2/sites-available/....-le-ssl.conf config file (or similar one with corresponding domain title and with ssl prefix or postfix in it's name).
After editing that file do not forget to restart Apache2 webserver with $sudo service apache2 restart and test website again.
I'm trying to run a simple webservice to get a XML list of customers but, when getting http://www.myshopurl.com/api/customers, PS redirects to frontpage.
Mod_rewrite is on in apache (checked with phpinfo function). Think that .htaccess is well formed:
# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com - http://www.prestashop.com/forums
<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#Domain: www.mydomain.com
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api$ api/ [L]
RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
</IfModule>
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|svg)$">
Header add Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404
# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
Im using Prestashop 1.6.0.14 and PHP Version 5.5.9-1ubuntu4.19. Added new webservice and activated.
In other way, I've configured my 000-default.conf apache file as this:
<VirtualHost 127.0.0.1:8080>
DocumentRoot /opt/prestashop_folder/
ServerName mydomain.com
ServerAlias www.mydomain.com
<Directory /opt/prestashop_folder>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Don't know if you need more data. Thanks for your time.
Ok, sorry dudes, problem found.
Server has a NGinx and Apache working at same time. I though that apache was working with prestashop's front but I was wrong. Nginx is.
Nginx config had a rule that redirected all URL's to index.php. I've added new rule to /api/* and problem solved.
PrestaShop Nginx Configuration
rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
https://gist.github.com/julienbourdeau/79961e9caa4263e9e34d2d056948d335
I've created a simple Zend Framework 1.12 test app via the zf.bat on my windows machine (xampp, php5.3): "zf create project testapp"
After that i've created an new controller called 'FoobarController' next to the 'IndexController'.
Now I can switch between these urls:
localhost/projects/testapp/public/
localhost/projects/testapp/public/index
localhost/projects/testapp/public/foobar
Now I have uploaded the whole testapp into the web server directory of my raspberry pi (192.168.1.100, Apache2, PHP5.3, ModRewite On, AllowOverride All).
This urls are working fine when I call the raspberry from the windows machine:
192.168.1.100/sites/testapp/public
192.168.1.100/sites/testapp/public/foobar
This one will display: "The requested URL /sites/testapp/public/index was not found on this server"
192.168.1.100/sites/testapp/public/index
Has someone an idea why the url to the "index" controller wont work properly on my raspberry? (I did nothing more than the explained steps)
/etc/apache2/sites-available/default:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
.htaccess:
RewriteEngine On
RewriteBase /sites/testapp/public
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
I've searched the site thoroughly and Googled for this as well, but to no avail.
I use Apache2 + PHP on my Mac OS X.
I haven't changed much of the configuration on any of them, just enough to get everything working correctly.
Here's my .htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteBase /~milad/mysite/
RewriteEngine On
RewriteRule ^$ index.php?:url [L,QSA] #Handling tail with no parameters
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*?)$ index.php?:url=$1 [L,QSA]
</IfModule>
This works just fine for all the files located at http://localhost/~milad/mysite/*.
But I want to make my .htaccess file independent of my installation's particulars, i.e., I don't want to have to include the RewriteBase ... line in my code.
But when I remove that line, Apache tries to map it to a URL which I don't understand.
What I get is:
Not Found
The requested URL /Users/milad/Sites/newave/index.php was not found on this server.
which is just ridiculous, because the index.php file is JUST where that URI is pointing to.
Anyway, when I try to rewrite to /index.php instead of index.php, I find that it is being rewritten to http://localhost/index.php. So how is it that I can't use just the relative path, or just use ./index.php (Yes, I've tried that, too).
Any insight would be greatly appreciated.
The problem comes from your vhost configuration:
Not Found
The requested URL /Users/milad/Sites/newave/index.php was not found on this server.
Means clearly: "the base of your site is /Users/milad/Sites/newave/".
So if you want the base for you site to be /~milad/mysite/ try to change the DocumentRoot
<VirtualHost *>
ServerName mysite.com
DocumentRoot "/~milad/mysite/"
</VirtualHost>
Of course, all the files of you site must be in the folder "/~milad/mysite/".
Then in your htaccess file (notice that ^(.*?)$ is equivalent to (.*) and I don't understand why you need the RewriteRule ^$ because it should be handled properly at the end):
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?:url=$1 [L,QSA]
Please tell me if it works
Edit: Following the comments, here's a vhost file that works for me:
<VirtualHost *>
DocumentRoot "/web/htdocs/olivier/wwog"
ServerName wwog.fr
ServerAlias *.wwog.fr
ErrorLog "/web/logs/wwog.error.log"
CustomLog "|/opt/httpd/bin/rotatelogs /web/logs/wwog/access.%Y-%m-%d-%H_%M_%S.log 5M" combined
DirectoryIndex index.php index.htm
<Location />
# Compression:
# (http://httpd.apache.org/docs/2.0/mod/mod_deflate.html)
# Insert filter
AddOutputFilterByType DEFLATE text/html text/plain
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
# Add "Cache-control: public" = valid for 480 weeks
# for proxies to keep images in cache:
<FilesMatch "\.(ico|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>
# Forbid files that start with "_"
<FilesMatch "^_">
Order allow,deny
Deny from all
Satisfy all
</FilesMatch>
# Forbid .htaccess and .htpasswd
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy all
</FilesMatch>
<Directory "/web/htdocs/wwog">
Order allow,deny
Allow from all
Deny from none
AllowOverride All
</Directory>
</VirtualHost>