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
Related
I have a laravel 5.4 application in a server, and I get this result when I try to test my app.
My virtual host file
<VirtualHost *:80>
ServerName plataformafoodif.cl
DocumentRoot "/var/www/html/Plataforma-FoodIf/public"
ServerAlias www.plataformafoodif.cl
<Directory "/var/www/html/Plataforma-FoodIf/public">
Options All
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
My index.php file
<?php
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
My .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
My hosts file
# Generated by SolusVM
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
# 168.232.167.108 FRESBOX.CL
168.232.167.108 plataformafoodif.cl
Also on my .env I have
APP_ENV=local
APP_DEBUG=true
APP_KEY=someRandomKey
APP_LOG_LEVE=debug
APP_URL=http://168.232.167.108
Any help would be really appreciated, I have spent many hours trying to fix this
Hi there can you try this:-
<VirtualHost *:80>
ServerName plataformafoodif.cl
DocumentRoot "/var/www/html/Plataforma-FoodIf/public"
ServerAlias www.plataformafoodif.cl
<Directory "/var/www/html/Plataforma-FoodIf">
Options All
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
and also you have to configure the apache2.config file.
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
You will find the above code in your apache2.conf file where you add your path to the third directory.
And then reload the apache server. I hope this helps your problem.
In the end it was this
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
I've changed to index.php to match my file on public and i also added the php module line
LoadModule php7_module modules/libphp7.so
Thanks your all your help
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>
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
Hello I am currently trying to set up dynamic subdomains picked up from my database on my codeigniter installation whenever i try to access a subdomain i get a 403 error I realize a couple of issues might be causing this I however cannot determin which one it is I am sorry if I am asking an obvious question but i a quite new to this
here is my virtual host set up
<VirtualHost *:80>
DocumentRoot /var/www
ServerName www.example.mobi
ServerAlias example.mobi
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
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
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/subs
ServerName example.mobi
ServerAlias *.example.mobi
<Directory /var/www/subs/>
# Options +Indexes
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
Here is my .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#this is to allow no indexes
Options All +Indexes
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
AddType image/x-windows-bmp bmp
This is the error i see when i try and access a subdomain
[error] [client x.x.s.x] Directory index forbidden by Options directive: /var/www/subs/
Additional information would be that i am using this guide
http://code.tutsplus.com/tutorials/basecamp-style-subdomains-with-codeigniter--net-16330
to set up my codeigniter for the subdomains
*also when i access the domain
"domain.mobi"
'domain' is echoed as i have set it to echo the subdomain
I since found a solution the subdomain virtual host just needs to be pointed to the same directory as the main domain and then I can use the subdomain as a parameter
<VirtualHost *:80>
**DocumentRoot /var/www**
ServerName example.mobi
ServerAlias *.example.mobi
<Directory /var/www/subs/>
# Options +Indexes
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
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