Someone help me.
.htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
config file
$config['base_url_front'] = 'http://example.com;
$config['base_url'] = 'http://example.com';
$config['post_image_url'] = $config['base_url'].'assets/images/post_image/';
$config['post_video_url'] = $config['base_url'].'assets/images/post_video/';
$config['art_image_url'] = $config['base_url'].'assets/images/art_image/';
$config['media_video_url'] = $config['base_url'].'assets/images/media_video/';
$config['parent_folder_name'] = $_SERVER['DOCUMENT_ROOT'].'/';
directory structure
[![enter image description here][1]][1]
site available file config:
ServerAdmin webmaster#localhost
ServerName example.com
DocumentRoot /var/www/html/sourcedirectory
<Directory /var/www/html/sourcedirectory/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
I would appreicate any advice... Thanks.
[1]: https://i.stack.imgur.com/yTGkX.png
Related
I've developed a web Zend-framework2 application on windows everything worked fine.
I want to deploy my project to my server on RHEL 6.5. I've tried everything but I can't do so.
This is my project structure
|--zend
|--config
|--data
|--module
|--Application
|--...
|--public
|--index.php
|--.htaccess
|--vendor
|--init_autoloader.php
This is the content of .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
This is the content of index.php
chdir(dirname(__DIR__));
// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server') {
$path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
if (__FILE__ !== $path && is_file($path)) {
return false;
}
unset($path);
}
// Setup autoloading
require 'init_autoloader.php';
// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
my php version is 5.3,rewrite_mod is on
i've add virtualhost to the httpd.conf like so
<VirtualHost *:80>
ServerName zend.local
DocumentRoot /var/www/zend/public
<Directory "/var/www/zend/public">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
what should id do ?
We have a multi lingual website with the structure like /content/<app>/<language>/login-page , I am looking to get rid of /content/<app>/<language>and the .html from the URLs, so that instead of accessing pages like http://www.application.com/content/<app>/en/login-page.html or http://www.application.es/content/<app>/en/login-page.html I can access the page like http://www.application.com/login-page and http://www.application.es/login-page. As far as I know this has to be taken care of using Sling Mappings and Rewrite Rules in Apache. But not exactly sure how to achieve that. What the mappings will be in both apache and the Sling Mappings ?
There is an excellent write up on this here :
http://www.cognifide.com/blogs/cq/multidomain-cq-mappings-and-apache-configuration#.VP-psmSUc44
Since you have two domains , you will need two mappings in etc/map. Something like this :
{
jcr: primaryType: "sling:OrderedFolder",
www.application_com: {
sling:internalRedirect: ["/content/application/en.html"],
jcr:primaryType: "sling:Mapping",
sling:match: "www.application.com/$"
},
www.application.com: {
sling:internalRedirect: ["/content/application/en"],
jcr:primaryType: "sling:Mapping",
redirect: {
sling:internalRedirect: ["/content/application/en/$1","/$1"],
jcr:primaryType: "sling:Mapping",
sling:match: "(.+)$"
}
},
www.application_es: {
sling:internalRedirect: ["/content/application/es.html"],
jcr:primaryType: "sling:Mapping",
sling:match: "application.com/$"
},
www.application.es: {
sling:internalRedirect: ["/content/application/es"],
jcr:primaryType: "sling:Mapping",
redirect: {
sling:internalRedirect: ["/content/application/es/$1","/$1"],
jcr:primaryType: "sling:Mapping",
sling:match: "(.+)$"
}
},
}
Rewrite rules for .com in web server :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName www.application.com
DocumentRoot /opt/cq/dispatcher/publish
<Directory /opt/cq/dispatcher/publish>
Options FollowSymLinks
AllowOverride None
</Directory>
<IfModule disp_apache2.c>
SetHandler dispatcher-handler
</IfModule>
RewriteEngine On
RewriteRule ^/$ /content/application/en.html [PT,L]
RewriteCond %{REQUEST_URI} !^/apps
RewriteCond %{REQUEST_URI} !^/bin
RewriteCond %{REQUEST_URI} !^/content
RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{REQUEST_URI} !^/home
RewriteCond %{REQUEST_URI} !^/libs
RewriteCond %{REQUEST_URI} !^/tmp
RewriteCond %{REQUEST_URI} !^/var
RewriteRule ^/(.*)$ /content/application/en/$1 [PT,L]
</VirtualHost>
Rewrite rules for .es in web server :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName www.application.es
DocumentRoot /opt/cq/dispatcher/publish
<Directory /opt/cq/dispatcher/publish>
Options FollowSymLinks
AllowOverride None
</Directory>
<IfModule disp_apache2.c>
SetHandler dispatcher-handler
</IfModule>
RewriteEngine On
RewriteRule ^/$ /content/application/es.html [PT,L]
RewriteCond %{REQUEST_URI} !^/apps
RewriteCond %{REQUEST_URI} !^/bin
RewriteCond %{REQUEST_URI} !^/content
RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{REQUEST_URI} !^/home
RewriteCond %{REQUEST_URI} !^/libs
RewriteCond %{REQUEST_URI} !^/tmp
RewriteCond %{REQUEST_URI} !^/var
RewriteRule ^/(.*)$ /content/application/es/$1 [PT,L]
</VirtualHost>
[All rules have been adapted from the link mentioned above]
Extensionless url's don't work in Sling , so you will have to re write url's from webserver to add them and then
write linktransformer in aem to remove them form the links in the html , here's a link to a post that explains this
http://www.citytechinc.com/us/en/blog/2013/04/extensionless-urls-in-adobe-experience-manager.html
We're currently creating an application with ZEND that we'd like to be able to set the environments through a second parameter IN FRONT of the domain.
Something like this:
app.production.mysite.com
App would indicate the folder (mysite.com/app), production the environment and mysite our domain.
You can use apache2 aliases together with mod_rewrite rules in order to achieve that.
This is an example httpd.conf section which setup a root zend framework app in /var/rootapp, and 2 other separated ZF apps under app1 & app2 folders.
<Directory "/var/app1/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
RewriteEngine On
RewriteBase /app1
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</Directory>
<Directory "/var/app2/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
RewriteEngine On
RewriteBase /app2
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</Directory>
<VirtualHost *:80>
ServerName app.production.mysite.com
DocumentRoot /var/rootapp/public
Alias /app1 /var/app1/public
Alias /app2 /var/app1/public
</VirtualHost>
My Apache config:
DocumentRoot /var/www
<VirtualHost *:80>
Alias /T "/var/www/Test"
<Directory /var/www/Test>
Options Indexes FollowSymLinks MultiViews
#AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
SetEnv APPLICATION_ENV "development"
Alias /N "/var/www/NCAA/public"
<Directory /var/www/NCAA/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride ALL
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 debug
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
My .htacess file in /var/www/NCAA/public:
RewriteEngine On
RewriteBase /N/
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I can go to files in localhost/T, but I get 404 for /localhost/N I get this in my apache log:
[Sun Nov 20 16:32:37 2011] [error] [client 127.0.0.1] File does not exist: /var/www/N,
so I'm not sure what I am doing wrong. I want 1 domain to be a regular domain with an alias and the other is a Zend app with a mod rewrute for the index.php
Thanks
Do you really need the NCAA app to be accessed under http://localhost/N? Is it acceptable to access it under a different url, like http://local.ncaa/?
If so, then a virtual host entry could look like:
<VirtualHost *:80>
DocumentRoot /var/www/NCAA/public
ServerName local.ncaa
SetEnv APPLICATION_ENV development
<Directory /var/www/NCAA/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride ALL
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 debug
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Then the standard ZF .htaccess can be used (no rewrite base required):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
All,
My Zend framework Application structure is like this:
billingsystem
-application
-design
--css
--struct.css
--icons
--styles
--images
--js
--common
--thirdparty
-public
--index.php
--.htaccess
-library
-- Zend
My Apache VHost is like this:
<VirtualHost *:80>
ServerAdmin webmaster#billingsystem.localhost
DocumentRoot /opt/lampp/htdocs/xampp/billingsystem
ServerName billingsystem
ErrorLog logs/billingsystem.localhost-error.log
CustomLog logs/billingsystem.localhost-access.log common
<directory /opt/lampp/htdocs/xampp/billingsystem>
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
My .htaccess in public folder is like this:
RewriteEngine on
# The leading %{DOCUMENT_ROOT} is necessary when used in VirtualHost context
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -l [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
If I browse to http://billingsystem, it shows the apache directory path on the browser. If I go to http://billingsystem/public, the application executes code on the web page. Is it possible to create or modify .htaccess file such that, when a user browses to http://billingsystem, it should redirect the browser to http://billingsystem/public and execute the code instead of showing the directory structure?
Also, how can I redirect the user to "public" directory when he tries to access any folder through the browser?
I just went through something like this on a site. My solution was that I needed to use two .htaccess files on the domain. One in the root level of the site and another in the public folder.
So, the one at the root of the domain looks like this:
<Files .htaccess>
order allow,deny
deny from all
</Files>
Options +FollowSymLinks
RewriteEngine On
#Zend Rewrite Rules
RewriteRule ^(.*)$ /public/$1 [NC,L]
AddHandler php5-script .php
Within the public folder I have the following rules in place:
<Files .htaccess>
order allow,deny
deny from all
</Files>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*)$ index.php [NC,L]
This seems to work well to get all content trafficking through the Zend framework.
Hope this is helpful.
- liam
To directly answer your question you can place a .htaccess directly in the billingsystem folder with a rewrite rule:
RewriteRule ^(.*)$ /public/$1 [NC,L]
However, your setup should look more like the following:
File System
billingsystem
-application
-design
-public
--index.php
--.htaccess
-library
-- Zend
Virtual Host
<VirtualHost *:80>
ServerAdmin webmaster#billingsystem.localhost
DocumentRoot /opt/lampp/htdocs/xampp/billingsystem/public
ServerName billingsystem
ErrorLog logs/billingsystem.localhost-error.log
CustomLog logs/billingsystem.localhost-access.log common
<directory /opt/lampp/htdocs/xampp/billingsystem/public>
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Now the question that remains is that i know you have stuff in you design directory that aparently needs to be web accessible... Can you elaborate on the directory structure in design so that we can figure out what you need to do (if anything) to properly access the various types of files contained in it?