I feel like I have no idea what I'm doing.
My CodeIngiter application is working fine in WAMP using this URL: http://localhost/myapp.
However, when I moved it to my AWS EC2 micro instance Amazon Linux AMI /var/www/html/myapp and tried to access my application using this URL, http://xxx-xxx-xxx-xxx-xxx.compute-1.amazonaws.com/myapp, all I get is a blank white page.
Here is everything I tried:
1. Disabled "Index of" display
cd /etc/httpd/conf/
sudo nano httpd.conf
Options -Indexes FollowSymLinks
2. Turned on Error reporting in php.ini
error_reporting = E_ALL | E_STRICT
display_errors = On
3. Development Environment
In the index.php (root of my applicaiton),
define('ENVIRONMENT', 'development');
4. Restarted Apache
cd /etc/init.d
sudo httpd -k restart
5. DocumentRoot
DocumentRoot "/var/www/html/"
Also tried:
DocumentRoot "/var/www/html"
DocumentRoot "/var/www/html/myapp"
6. echo test from index.php
I printed a test message from both my index.php
(root of my app), as well as my controller. Both
worked. I don't understand why my view is not being
displayed.
<?php echo "test"; ...
//This worked.
7. Replaced www/html/myapp with www/html/
I moved the contents of my application outside of "myapp"
folder into www/html directory.
Also, DocumentRoot "/var/www/html/".
Also, my .htaccess file (in root of myapp)
is "RewriteBase /" (see point 8 below).
Also, I removed .htaccess from /var/www/html/
but same blank page.
8. .htaccess
The following .htaccess file is located in the root
of my CodeIgniter application. I also tried changing
RewriteBase /myapp to RewriteBase / but I'm still
getting this blank page with no errors.
RewriteEngine On
# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/
RewriteBase /myapp
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
I do not know what to try again.
Related
I have followed these steps to remove index.php from url. I am working on laravel 5 and i have followed the insrtuection to remove index.php and public from url..but after i am not able to access my views folder and pages using url.Only main link like www.art.local is working www.art.local/index/register this is not working.
Please Help
Renaming the server.php to index.php (no modifications)
Copy the .htaccess from public
Changing .htaccess it a bit as follows for statics:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_URI} ! (\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]
In Laravel 5, by default, you don't need to include index in your URL. For example, lets say we have this route:
Route::get('register', function () {
return 'Hello world';
}
So if you try to go to localhost/register, You'll get Hello World output.
Update 1:
IIR, If you're using services like "WampServer" to run your server, you should enable module_rewrite in your Apache and then restart it. For more informatiom, please see this answer - https://askubuntu.com/questions/48362/how-to-enable-mod-rewrite-in-apache
To move your site main url from public in windows you should make a vitual host.to do this first open
1.Open the XAMPP control panel application and stop Apache. Be aware that late Windows machines might run it as a service, so check the box to the left of the Apache module.
2.Navigate to C:/xampp/apache/conf/extra or wherever your XAMPP files are located.
3.Open the file named httpd-vhosts.conf with a text editor.
4.Around line 19 find # NameVirtualHost *:80 and uncomment or remove the hash.
At the very bottom of the file paste the following code:
<VirtualHost *>
ServerAdmin admin#localhost.com
DocumentRoot "C:/xampp/htdocs" # change this line with your htdocs folder
ServerName localhost
ServerAlias localhost
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Now you can copy and paste the code above below to add your Virtual Host directories. For example I’m working on a site called Eatery Engine so the following snippet will allow me to work with sub-domains on my local install:
<VirtualHost eateryengine.dev>
ServerAdmin admin#localhost.com
DocumentRoot "C:/xampp/htdocs/laravel-projcet/public"#path to your project #in laravel project be sure to set path to public folder
ServerName eateryengine.dev
ServerAlias eateryengine.dev
<Directory "C:/xampp/htdocs/eateryengine">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
7.Next head over to your Windows host file to edit your HOSTS. the file will be located at C:/Windows/System32/drivers/etc/hosts, where hosts is the file. Open it with notepad.
Look for
localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
Add your project name with bottom of this line (This is DNS ADDRESS OF YOUR DOMAIN)
127.0.0.1 localhost
127.0.0.1 eateryengine.dev #change to match your Virtual Host.
127.0.0.1 demo.eateryengine.dev #manually add new sub-domains.
Restart Apache and test everything.
now you can access your site without typing localhost or public in url just type domain name which you have register in httpd-vhosts.conf file
The original article for setting virtual host in windows can be found here http://austin.passy.co/2012/setting-up-virtual-hosts-wordpress-multisite-with-xampp-on-windows-7/
thanks sunny but already i have created virtual host..and working in linux... Route::get('/','UserController#index'); Route::get('/user','UserController#myaccount');
www.loveart.dev/ then fisrt is working.
www.loveart.dev/user second don't working
i have 2 folder a and b
I want to rewrite url as like subdomain style.
domain.com/a => a.domain.com => it will run folder a
domain.com/b => b.domain.com => it will run folder b
Thanks in advance
Assuming the folders a and b are at the root of your domain, try adding this to the .htaccess file in your web document root folder (often public_html or htdocs):
Options -Multiviews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([ab])\.domain\.com [NC]
RewriteRule ^ %1%{REQUEST_URI} [L]
This assumes that mod_rewrite is both installed and activated for .htaccess files.
If you are not sure, to check if mod_rewrite is even installed, look at the list of installed modules in the output of phpinfo();
By default, mod_rewrite is not enabled for .htaccess files. If you are managing your own server, open httpd.conf
and make sure that the webroot directory block contains one of these lines: AllowOverride FileInfo or AllowOverride All
I have set up a wordpress multisite installation on my xampp localhost.
I went to update xampp this morning to a newer version, and it screwed my database. I've since re-installed the older version of xampp, re-imported my database and re-imported my sites folder to htdocs.
I had it set up so I could go to mysite.com and it would direct me to the correct sub folder.
Now when I go to localhost or mysite.com it redirects me to localhost.
If I do localhost/mysite then I get a 404 error not found.
Did I miss a step?? Database is re-imported and connected, my .htaccess file is set up properly (as I didn't change any of the settings) and my wp-config.php file is set up correctly (again didn't touch it).
Thanks
Ok as per a request I'm including my .htaccess. I know that it is set up correctly.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
I was able to resolve the issue. I forgot to set up a virtual host inside of my
httpd-vhosts.conf file:
First I uncommented this line (removed the hashtag(#)) :
NameVirtualHost *:80
Next I added this to the bottom:
<VirtualHost *:80>
DocumentRoot "S:/Server Files/XAMPP/htdocs/MySiteFolder/" #path to site directory
ServerName mysite.com #url you would like to type in url bar to hit your site
</VirtualHost>
Hopefully this helps someone, as I just sat here for 4 hours trying to figure this one out.
I just cleared the browser Cache and it worked.
I am currently having an issue using the URL manager and/or the apache mod_rewrite or maybe something else entirely.
With showScriptName set to false, navigating to addresses such as domain.com/login, domain.com/logout, domain.com/site/login are all behaving the same way. It simply shows the main site/index, as if I were to navigate to domain.com/eeofjew9j8jfdedfmewf (jibberish).
Maybe it's an issue with my Yii settings? Here are those (sorry for the sloppiness):
'components'=>array(
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'login'=>'site/login',
'logout'=>'site/logout',
'register'=>'users/register'
),
,...
Here is how I have my .htaccess setup in the www root:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
I am using a VPS server, so I have root access to make any changes needed to apache. I've checked my phpinfo and mod_rewrite is running and enabled. In my apache config, I have for my www directory:
AllowOverride All
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
I've been scratching my head on this issue through 3 different hosts (godaddy, dreamhost, and lithiumhosting) so I'm assuming it's an issue on my end with this. Now that I have a VPS though, I'm hoping I can finally figure out my issue and solve it.
First verify that the server is parsing the .htaccess file. This is simply done by placing random text in the .htaccess file such as
CREATE AN ERROR
If this gives you a server error then the file is being parsed. You may have to move the .htaccess file up a directory to get this to work.
After this is working check to make sure the rewrite module in Apache is on. First check phpinfo and look for the running module. If not you may have to delete the comment (#) character in front of the module.
After the module shows up in phpinfo then see if you can do a basic rewrite to make sure that there are not problems with Apache.
RewriteEngine on
RewriteRule ^ http://google.com/? [L,R]
If that is not working try adding the
Options +SymLinksIfOwnerMatch
to the file
Once you have Apache doing it's part now it is up to yii. This code:
RewriteEngine On
RewriteBase /mybasedirectory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
adds the rewrite base option which may be necessary if you do not have the files in the document root such as htdocs
finally if that does not solve the problem then limit your rule to a simple rule such as
'contact'=>'site/contact',
and see if at least redirects to where you think it should. Of course you may have to check the basic rules of .htaccess again to make sure that overide is allowed and there isn't an errant .htaccess in a subdirectory. I hope that helps. I finally got mine working.
What happens if you delete these lines!
enter code here
# otherwise forward it to index.php
RewriteRule . index.php
if you add this code see if it works
'<action:(login|logout|register|contact)>' => 'site/<action>',
I have weird problem. I have to modify old CodeIgniter project.
Im using local windows XAMPP server for development, and my project was working on XAMPP.
Few weeks ago I reinstalled operating system . I installed XAMPP (same version) and i moved htdocs from default c:\xampp\htdocs to e:\htdocs. I had no problems with XAMPP with moved htdocs (other non-codeigniter projects are working fine).
Today I copied application from production server to my localhost and it's not working.
When I try to open in browser: http://localhost/myprojectfolder im getting blank page.
Clean CodeIgniter installation on local windows XAMPP works (however clean installation is not using .htaccess).
Project is working normally on production web server with .htaccess file like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myprojectfolder
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
# RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
# RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# 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]
# 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>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
I dont remember, that i had separate .htaccess file for localhost or not. If I had - it was overwritten by file from production server.
MySQL database used in project is identical on both servers (name, user, password, structure etc.).
My $config['uri_protocol'] is set to AUTO and it was working on XAMPP with AUTO.
My file permissions in htdocs are fine (user that is starting httpd.exe service can read and write there).
My routing:
$route['default_controller'] = "home";
$route['admin'] = 'admin/start';
$route['404_override'] = '';
Any ideas?