I am using HMVC with Codeigniter-3.x using MX for both backend and frontend. whole project are in a subdomain.
Frontend is working well in both localhost and online domain.
In localhost backend is also working well.
But backend not working on online domain.
the url from the modules are 404.
I have used to define base url as
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
Is there any routing solution for hmvc loader?
My project structure is here.
mydomain.com
/subdomain
/system
/asset
/application
/controllers
/models
/views
/modules
/module_1
/controllers
/models
/views
/third_party
/MX
/core
/helper
/config
/....
/backend
/asset
/application
/controllers
/models
/views
/modules
/module_1
/controllers
/models
/views
/third_party
/MX
/core
/helper
/config
/....
I think it is good practice to use single application folder.
For backend you may create a module name with Backend/Admin and keep your controllers their. Hope it will work fine...
Related
I enable force SSL via .htaccess. it's working fine and redirects to https://www.myappurl.com. Inside my application, I use Ajax to retrieve the category list. after SSL enabled category list not loading. it's shown without SSL URL http://www.myappurl.com. I also change APP_URL to https://www.myappurl.com in .env File
my .htacccess code
RewriteEngine On
# ensure www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# ensure https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Ajax Code
$.ajax({
url: '{{url('getsateslist')}}',
type: "POST",
dataType: "json",
The secure_url() helper function generates a fully qualified HTTPS URL to the given path, change :
url: '{{ url('getsateslist') }}',
To
url: '{{ secure_url('getsateslist') }}',
See the official documentation of [secure_url()] here
Seeing as you're using X-Forwarded-Proto to determine the protocol then I'm assuming your site is behind a proxy which terminates the SSL request and the proxy itself connects to your site using HTTP then you need to enable the "trusted proxies" middleware
You can find a basic implementation on github (and it does come with the Laravel boilerplate) but you can implement your own as well.
For example if you're using an AWS load balancer you can do:
<?php
namespace App\Http\Middleware;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
protected $headers = Request::HEADER_X_FORWARDED_AWS_ELB;
}
This uses the package TrustedProxy which is a Laravel dependency so more information can be found there.
I have installed a fresh installation of laravel and everything is working fine except that if I go to the url without entering the index.php at the end, then it doesn't work.
I am using:
http://localhost/index.php
And in this case, the page appears correctly but if I enter only:
http://localhost/
Then it is not working as expected.
How to see if it works or not, I have installed the debugbar and in the first case it is showing but in second case it is not.
I have update the apache2 config so that it starts in the public directory and also I made sure that it accepts php with DirectoryIndex index.php in the 000-default.conf.
Should I set up something so that it forces a redirect to index.php when hitting the directory in the browser?
Here is what I get from my phpinfo for the loaded modules in apache2 handler, I can see the mod_rewrite
Loaded Modules
core mod_so mod_watchdog http_core mod_log_config mod_logio mod_version mod_unixd mod_access_compat mod_alias mod_auth_basic mod_authn_core mod_authn_file mod_authz_core mod_authz_host mod_authz_user mod_autoindex mod_deflate mod_dir mod_env mod_filter mod_mime prefork mod_negotiation mod_php7 mod_reqtimeout mod_rewrite mod_setenvif mod_status
please change the contents of httpd.conf file like as below.
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>
...
Listen 8094
<VirtualHost *:8094>
DocumentRoot "D:\yoursouce\public"
<Directory "D:\yoursouce\public">
Require all granted
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
...
Then try
http://localhost:8094/
Best Regards
I have a VPS running WHM and Cpanel. I have multiple domains hosted there. Say one of them is example.com
What I am intending to do is have two versions of the application.
Production: example.com > /public_html/
Development: staging.example.com > /public_html/staging/
Right now, I am trying to deploy my application to the development environment, i.e to the staging folder.
Envoyer, with a lot of struggle with my hosting provider, is working fine. It's uploading the files as expected. The only issue now is the symbolic link current
Right now the folder structure is:
-staging
- releases
-release1
-release2
- current
My subdomain clearly points out to the staging folder, which will lead it to display all the contents of the folder rather than the application.
Since the application is inside the release folder, how do I make sure that my application runs when we hit the subdomain.
Do I have to modify my virtual hosts file in Apache?
Laravel requires the root for the domain (configured in the relevant apache vhost conf file) to be it's 'public' folder. This is where it's entry point index.php is.
Edit the apache vhosts conf file as per below
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/home/user/public_html/public"
<Directory "/home/user/public_html/public">
Options Indexes FollowSymLinks
AllowOverride all
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName staging.example.com
DocumentRoot "/home/user/public_html/staging/public"
<Directory "/home/user/public_html/staging/public">
Options Indexes FollowSymLinks
AllowOverride all
Allow from all
Require all granted
</Directory>
</VirtualHost>
For example.com you install your laravel application into /home/user/public_html folder.
As part of the laravel install it will create the 'public' folder.
For staging.example.com you install your laravel application into /home/user/public_html/staging folder.
Don't forget to restart the web server so it picks up the new configuration.
If you do not have the ability to change the vhost configuration mentioned above, you can use .htaccess file in your public_html folder (note the leading full stop which makes it a hidden file). The following is dependant on your hosting provider allowing .htaccess overrides.
Add the following to the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
If domain has been set up correctly by the host to point to /home/username/public_html when entering http://example.com then it should automatically call public/index.php.
You will need to do the same in public_html/staging folder.
So I had trouble while installing Prestashop 1.7 correctly and thought I would post my own guide to install it with Homestead (vagrant, virtualbox):
There we go:
Download prestashop
Have vagrant and homestead installed
Cd into your homestead folder and run vagrant - vagrant up
Extract ONLY THE FIRST zip in "...code\prestashop" folder
Configure homestead.yaml file by adding:
sites:
- map: prestashop.test
to: /home/vagrant/code/prestashop
php: "7.0"
databases:
- prestashop
add 192.168.10.10 prestashop.test to your hosts file
run vagrant provision
Open "prestashop.test" (or whatever other name you put in the homestead.yaml file) in browser
Proceed with prestashop installation
Comment out (_install) or delete the install folder (otherwise you will get an error when trying to open prestashop in the browser)
vagrant ssh
In vagrant ssh cd /etc/nginx/sites-available and run ls to see if prestashop is present
sudo nano prestashop.test
Add this between root and index and change the admin name on BOTH lines to your generated unique one:
location /admin/ {
if (!-e $request_filename) {
rewrite ^/.*$ /admin/index.php last;
}
}
then sudo /etc/init.d/nginx reload
Open prestashop.test/admin() (in the brackets put your unique admin name (without the brackets) and voilà!
Instead of having to edit Nginx config file you can simply use Apache, all that you have to do is to specified apache as a site type:
sites:
- map: prestashop.test
to: /home/vagrant/code/prestashop
php: "7.0
type: "apache"
It looks like there are some issues with Nginx that require to edit the config by hand just as #Todor did, more info here Does PrestaShop 1.7 work with Nginx? - General topics - PrestaShop Forums
In PS version: 1.7.6.7 i was forced to uncoment those two lines in .htaccess located in admin folder:
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)) %{ENV:BASE}/$2 [R=301,L]
Before that for links like: http://presta17.shop/admin466vvxojo/improve/modules/manage?_token=ZrnM85TEsROusexXinPySyjZQghmfHO7d7sSFI3Tgm4
with /index.php/ i get only: Access denied.
I'm sorry for this as there has been lots instances of such question, but I can't get through.
Request
In the Symfony2 project, I want to access pages without having the php controller in the URL, e.g :
# This is the present use :
GET /af/index.php/myURI HTTP/1.1
OK
~
# And this is the wanted use :
GET /af/monURI HTTP/1.1
But I get a 404 error, either with the default .htaccess or an own version.
.htaccess
Default .htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
I modified this as follows :
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteBase /af
# Options +FollowSymLinks
# Isn't the request for a regular file ?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Directory Structure
Here is my directory structure :
/var/www/af
├── app
├── bin
├── src
├── vendor
└── web
├── app_dev.php
├── apple-touch-icon.png
├── bundles
├── config.php
├── favicon.ico
├── .htaccess
├── index.php
└── robots.txt
I have dynamically linked the web/ directory to /var/www/af
Edit - I have found this :
When using the rewrite engine in .htaccess files the per-directory
prefix (which always is the same for a specific directory) is
automatically removed for the RewriteRule pattern matching and
automatically added after any relative (not starting with a slash or
protocol name) substitution encounters the end of a rule set. See the
RewriteBase directive for more information regarding what prefix will
be added back to relative substitions.
Don't change .htaccess file rules.
If you have access to webserver config files (i.e. local dev or virtual machine), then you need to add VirtualHost rule into httpd.conf.
Something like this:
<VirtualHost *:80>
DocumentRoot "/var/www/af/web"
ServerName af
<directory "/var/www/af/web">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
If you don't have access to webserver config files (i.e. shared hosting), then you need to have web folder linked as the public access folder (sometimes named public_html)
Problem solved, thanks to Mac : My document root didn't allow overrites for htaccess.