what will be my .htaccess setting? - php

I currently using CodeIgniter 3. It is working on my laptop.
But when I upload it to my Centos 6.9 server... I encounter an error.
I already check the mod_rewrite is loaded.
I want it to be like this URL/controller/method (no index.php after URL)
It shows me a 404 when i try to login which redirect me to this URL/gate/login
I also set this....
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
My htaccess on /var/www/html/calllist
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /calllist/index.php?/$1 [L]
</IfModule>
My httpd.conf
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<VirtualHost *:80>
ServerAdmin webmaster#xxxx.com
DocumentRoot /var/www/html/calllist
ServerName www.xxxx.com
ErrorLog /var/www/html/calllist/error_log
CustomLog /var/www/html/calllist/requests.log common
</VirtualHost>

i solved the issue.
apparently on httpd.conf, there is another line i need to set to 'All'.
and i added this to my virtual host
<Directory "/var/www/html/calllist">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Related

Installing laravel 5 in sub-directory

I wanted to isntall laravel in a sub directory inside my dev machine http://dev-machine/applis/main/laravel
My default document root is F:/data/web
My .htaccess file is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /applis/main/laravel
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
My httpd.conf file has below code
<VirtualHost *:80>
ServerName http://dev-machine/applis/main/laravel/public
DocumentRoot F:/data/web/applis/main/laravel/public
<Directory "applis/main/laravel/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I have also tried the belwo virtual host config
<VirtualHost *:80>
ServerName http://dev-machine/applis/main/laravel/public
Alias /laravel applis/main/laravel/public
DocumentRoot F:/data/web/applis/main/laravel/public
<Directory "/applis/main/laravel/public">
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
But stil I am unable to access the app via
http://dev-machine/applis/main/laravel/public
I am getting he below error
Not Found
The requested URL /applis/main/laravel/public/ was not found on this server.
After adding the virtual host when it is not even loading the index.php file when I try loading it directly via http://dev-machine/applis/main/laravel/public/index.php

Laravel 5.1 .htaccess not working (pretty url's)

So I have tried both versions of the .htaccess, the one that comes with it in project creation and the one in the documentation. I am currently using the one in the documentation:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I have my virtualhost set up like so:
<VirtualHost *:80>
ServerAdmin <my email>
ServerName projectflyer.<my domain>.com
DocumentRoot /var/www/html/projects/project-flyer/public
DirectoryIndex index.php
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
However when I go to projectflyer.mydomain.com/some/route I get back a 404. Any ideas? Yes I can go to the base url just fine.
I solved this by adding this to my virtualhost .conf file:
<Directory /path/to/your/install/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Thanks to http://laravel.io/forum/09-15-2015-removing-indexphp-from-url-laravel-5116 for the answer

Laravel5 Ubuntu only working when myvirtualdomain/index.php/subsites

I'm using Ubuntu 14.04. I have installed LAMP, Composer and I installed Laravel. I created virtual domain (laravel.dev) and it works, but only when I'm using for simple laravel.dev/index.php/auth/login. When I use laravel.dev/css I have laravel/public/css folder. I have default .htaccess file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
AllowOverride All
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And my *.conf file:
<VirtualHost *:80>
ServerName laravel.dev
ServerAdmin webmaster#laravel.dev
DocumentRoot /var/www/laravel/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
How can I fix it?
My main page:
http://i.imgur.com/AxQjV9q.png
I fall this problem.I solved it using apache mod rewrite enable.For that follow this
http://www.kingpabel.com/apache-mod_rewrite/
Currently, your virtualhost doesn't allow overriding the rewriting settings in the .htaccess of your project.
You should add the following lines to your .conf file, in the virtualhost :
<Directory "/var/www/laravel/public">
AllowOverride All
</Directory>
Which would result in the following file :
<VirtualHost *:80>
ServerName laravel.dev
ServerAdmin webmaster#laravel.dev
DocumentRoot /var/www/laravel/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/laravel/public">
AllowOverride All
</Directory>
</VirtualHost>

Xampp Virtual Host for sub directory

Question
I would like to map
www.mydomain.com/some/url
to
C:/xampp/htdocs/some/dir
What I've got
Xampp
Wordpress
htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /some/path/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /some/path/index.php [L]
</IfModule>
Hosts file
127.0.0.1 www.mydomain.com
httpd-vhosts.conf (included in httpd.conf)
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/someDir/"
ServerName mydomain.com/some/path
</VirtualHost>
additional info (httpd.conf)
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
Current Outcome
500 Internal Server Error error log shows
Request exceeded the limit of 10 internal redirects due to probable configuration error.
Add the alias to your httpd.conf
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
Alias /some/url C:/xampp/htdocs/some/dir

Apache's Alias directive is not working as expected

I am trying to integrate my portal with my website.
My website :
http://example.com
and My portal :
http://portal.com
Now I want to see my portal from :
http://example.com/portal
Part of my core apache config file (sites-enabled/website):
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName example.com
DocumentRoot /home/example/WebSite2.0/WebContent
DirectoryIndex index.php index.html
<Directory /home/example/WebSite2.0/WebContent>
Options +IncludesNOEXEC
AllowOverride None
Order allow,deny
allow from all
XBitHack On
AddType text/html .html
AddHandler server-parsed .html
</Directory>
Alias /portal /home/example/portal/CodeIgniter_2.1.0
<Directory /home/example/portal/CodeIgniter_2.1.0>
DirectoryIndex "index.php"
allow from all
Options +Indexes
#Options FollowSymLinks MultiViews
Order allow,deny
RewriteEngine On
RewriteBase /portal
#RewriteRule ^test\.html$ test.php
RewriteCond $1 !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond $1 ^(css|images|js)
RewriteRule ^(.*)$ $1
</Directory>
</VirtualHost>
As you see my portal functions on top of CodeIgniter; Hence -
RewriteCond $1 !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Part of my core apache config file (sites-enabled/portal) :
<VirtualHost *:443>
ServerAdmin webmaster#localhost
ServerName portal.com
ServerAlias www.portal.com
DocumentRoot /home/example/portal/CodeIgniter_2.1.0
DirectoryIndex "index.php"
SSLEngine On
SSLCertificateFile "ssl/portal.com.crt"
SSLCertificateKeyFile "ssl/portal.com.key"
<Directory /home/example/portal/CodeIgniter_2.1.0>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Header unset Server
ServerSignature Off
</Directory>
</VirtualHost>
Now the real problem is when I open http://example.com/portal the browser is looking for the images in the DocumentRoot and not in Alias.
e.g. for image from portal,
<img src="/images/example.png" style="margin-left:30px;height:50px;">
apache error log says -
File does not exist: /home/example/WebSite2.0/WebContent/images/example.png
I would hate to make changes to my code. I just want to get this thing working from the apache config file itself. Please help me do this.
RewriteBase /portal require that the url should begin with /portal. So:
RewriteCond $1 !^(index\.php|css|images|robots\.txt)
will not be hit.
<img src="/images/example.png" style="margin-left:30px;height:50px;">
will try to search file from DocumentRoot.
update1
For there is RewriteBase /portal, example.com/portal/images will hit the Rewrite rule, but example.com/images will not, so:
<img src="/images/example.png" style="margin-left:30px;height:50px;">
should be:
<img src="/portal/images/example.png" style="margin-left:30px;height:50px;">
update2
It is the answer given by #Hussain Tamboli himself, with:
RewriteRule /(images|js|css)/(.+)\.(.+)$ /portal/$1/$2.$3 [PT].
/images/Invoice.png will rewrite to /portal/images/Invoice.png

Categories