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
Related
I recently set out to compile a lamp stack from source. Apache was compiled like so:
./configure --prefix=/srv/www --enable-mods-shared=most
and I can confirm mod_rewrite is enabled by placing this in the vhost for a site:
Redirect "/foo.html" "/bar.html"
However, after installing wordpress, I can log in at example.com/wp-login.php, but example.com/wp-admin loads to an error page about a redirect loop.
I'm using the default wordpress htaccess file:
# 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
and this vhost:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/srv/www/htdocs/example.com"
<Directory "/srv/www/htdocs/example.com">
options indexes followSymLinks
# AllowOverride controls what directives may be placed in .htaccess files.
AllowOverride All
# Controls who can get stuff from this server file
require all granted
rewriteEngine on
</Directory>
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
ErrorLog /srv/www/logs/example.com/error_log
CustomLog /srv/www/logs/example.com/access_log combined
</VirtualHost>
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/srv/www/htdocs/example.com/$1
DirectoryIndex /index.php index.php
The ProxyPassMatch line is included to handle php via php-fpm.
I can include the httpd.conf if needed, but it's 506 lines long and I hear pastebin isn't received warmly here. I've checked the error log for that domain and it doesn't get updated when hitting the redirect loop, and it seems like a pretty straightforward setup with the exception of using php-fpm instead of mod_rewrite, so I'm a bit lost on where to check further.
This was compiled on centos7 so a2enmod isn't an option.
DirectoryIndex /index.php index.php
This was the issue.
DirectoryIndex index.php
This was the solution. After removing /index.php from the directoryindex directive, the site loads and the dashboard loads without issue as well.
I moved my shop from exampledomain.com/prestashop to differentdomain.com. Now if I go to differentdomain.com, the server provider tells me that I have to upload files into public_html, but if I type differentdomain.com/index.php everything works fine. I tried to modify the shop_url values in database, but this did not seem to have any effect. How can I make the shop appear when I go to differentdomain.com?
Here is my .htaccess:
# ~~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=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
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>
I'm getting a problem. I'm using Ubuntu and all my files are located in /var/www. It contains the following folder:
fatfree:contains the fat free framwork
F3Apps: contains index.php, .htaccess(contents shown below)
The content of the index.php is
<?php
require '../fatfree/lib/base.php';
F3::route('GET /',function()
{
echo "root entered";
});
F3::route('GET /about',function()
{
echo "about entered";
});
F3::run();
?>
When I'm setting the URL as http://127.0.0.1/F3Apps/, it is ok, i.e. it is echoing
root entered
However when I'm setting the URL as http://127.0.0.1/F3Apps/about, I'm getting the following:
The .htaccess contents is shown below(The .htaccess is in the file F3Apps):
# Enable rewrite engine and route requests to framework
RewriteEngine On
RewriteBase /F3Apps
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
# Disable ETags
<IfModule mod_header.c>
Header Unset ETag
FileETag none
</IfModule>
# Default expires header if none specified (stay in browser cache for 7 days)
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A604800
</IfModule>
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Options -Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from All
</Directory>
Check your .htaccess, problem is there. Or post it's content for us :)
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>