I have problem with my project. Because this is a secret, I can not publish my site here. I am sorry for this and this is my case.
I have a project based on the CodeIgniter framework, I run it successfully on localhost but when I use SVN to commit this project to my hosting. It do not run. I am trying to delete all file and commit only index.html with content is "test". Browser show result is "test". I am trying to commit this project again but result still is "test".
However, if I type index.php after my url "http://myaddress.com/index.php", I see my result which I would like. I have tried to config file "config.php" remove "index.php" in $config['index.php] = '' but nothing changes.
From the CodeIgniter's doc, check the "Remove the index.php file" on this page: http://www.codeigniter.com/userguide2/general/urls.html
And just to remember, have you enabled Apache's mod_rewrite?
Add .htaccess file with the following rule in root folder,
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
To make .htaccess work , you have to enable apache module mod_rewrite
If you have access to server, you can type the following command in the terminal (for linux servers, this example specific to ubuntu)
a2enmod rewrite
Restart apache2 after
/etc/init.d/apache2 restart
or
service apache2 restart
If you have not access to server, please contact server administrator.
Related
I'm trying to redirect my user to a certain website when they visit one of my end point.
https://url-shortner-in.azurewebsites.net/openfb will point to google.com
My server is hosted on Azure App Service with Slim Framework v4 using REST API.
This is my call to redirect the user.
return $response
->withHeader('Location', 'http://www.google.com')
->withStatus(302);
It's working fine on my local WAMP server. I'm getting redirected to Google.
But after uploading it on Azure App Service, the code isn't working.
I'm seeing a blank page after redirection. The URL stays the same (my website URL and not Google's.)
Is there any misconfiguration with Azure?
My .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
I suggest you choose windows platform when create webapps.
You can try to create web.config file under the wwwroot folder, if it doesn't exist. If you can find this file when deployed your webapp, you need to modify it.
The specific content to be added or modified is that RewriterConfig needs to be added to web.config.
The format is as follows:
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler,URLRewriter" />
</configSections>
......
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>^default/([0-9]+)/([_0-9a-z-]+)</LookFor>
<SendTo>11.aspx?id={R:1}</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
For more details, you can refer to the following two posts:
Azure Web App Angular Not redirecting to www
DNN UrlRewrite (“DotNetNuke.HttpModules.UrlRewriteModule, DotNetNuke.HttpModules”) does not run custom rewrite rule on web.config
Step 1: Enable Apache .htaccess
By default, the .htaccess file is not enabled.
1. Open the default host configuration file by entering the following command in the terminal:
sudo nano /etc/apache2/sites-available/default
2. Locate the section labeled <Directory /var/www>.
In that section, change the AllowOverride None entry to all:
AllowOverride All
Save the file and exit.
3. Next, restart the Apache service:
sudo systemctl apache2 restart
I have recently deployed a Laravel project to my live web server via FTP (Filezilla). Inside my young1.org web root folder I have the subdomain folder bookings, which displays web content at http://bookings.young1.org. Inside that folder I have the folder, 'laravel' that contains my entire laravel application, and inside that folder there is a 'public' directory.
I have imported my local database to one of the database accounts on the live web server via phpmyadmin, and I have switched the 'DB' credentials to point to the new database inside the env file in the laravel project root (changing the following variables: DB_DATABASE, DB_USERNAME, DB_PASSWORD).
When I navigate to http://bookings.young1.org/laravel/public, the home page of my application appears, fine and dandy. However, when I click on any of the internal links (e.g. the login and register) buttons, I just get a series of blank pages, and none of the internal pages appear.
Would anyone be able to take a guess at what the problem might be?
I have tried altering the .htaccess file to look like the below, and changing my 'PATHS' variable inside public/index.php.
Thanks,
Robert
London, UK
// public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
// public/index.php
require DIR.'/../laravel/bootstrap/autoload.php';
$app = require_once DIR.'/../laravel/bootstrap/app.php';
do you have SSH on the server? if yes did u install laravel as you're supposed to, also could you include the .env file contents, you can mask out the DB username and pass and the key you had to generate
never mind my mistake, i clicked on a link and got a SQL connection error (refused)
i still need to know if you installed laravel via SSH or that you just made the public folder the root, because if that's the case laravel cant help you with that (you need a VPS and not a webhost that only supports FTP as far as i know)
and to be sure
BE CAREFULL!!!
you have SQL connection errors that show credentials
Notice that your URLs work fine if you use index.php in them, i.e.:
http://bookings.young1.org/laravel/public/index.php/register
To allow URLs without index.php the mod_rewrite module on your Apache web server must be enabled.
First try to add this line in your .htaccess file of Laravel above RewriteEngine On:
Options +FollowSymLinks
This directive is needed to enable mod_rewrite in .htaccess context.
If it doesn't work after this, then you can check if module is enabled on your web server, the easiest maybe is to paste this in the beginning of index.php in public folder:
phpinfo();
Then open any page and search for mod_rewrite on the page, and see if you can find it under Loaded Modules. If not, you have to enable it.
To do that, if you can access through SSH you can do:
sudo a2enmod rewrite
sudo service apache2 restart
For more help on enabling mod_rewrite on Apache web server, check this answer.
I have freeBSD installed on IBM server. There is also apache, php and mysql installed on the server. A PHP application running on this machine is working just fine, but our new version of the same application developed in Codeigniter gives a "Page Not Found" error.
The thing is the application is accessible and runs well (only the non-english character are displayed not well) if the index.php is included in the url.
I have modified the file .htaccess to remove the index.php from the url, I kind of need to use the .htaccess in the application's root directory. This (using .htaccess) is actually causing the error.
Please let me know what configuration do I need to do.
Edit:
Bellow is the content of .htaccess in the root directory of the application:
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /football/index.php/$1 [L]
I need in the
url: domain.com/search/hola
to ignore this hola (so go to /search/index.php) but have this hola in a php variable.
For example i type domain.com/search/google in my browser, then go to domain.com/search/index.php with the code:
$search = $_GET['url']; //(obviously, this doesn't works)<br>
print_r($url);
Something like that: http://example.com/ put what you put go to the same site.
You can do this with a RewriteRule.
Install the module mod_rewrite into your Apache. Depending on your server and OS, instructions may differ, but most of the time it's already installed.
Check that AllowOverride All is specified in your Apache's site configuration to allow .htaccess files.
Create a .htaccess file in the root folder of your webserver.
RewriteEngine On
RewriteRule ^/search/(.*) /search/index.php?param=$1 [L,QSA]
If you do any changes in your apache configuration or install a new module, you will have to restart the apache service. Changes in a .htaccess file do not require a restart.
HowTo http://httpd.apache.org/docs/current/mod/mod_rewrite.html
I have a .htaccess file to remove the index.php part of the codeigniter-style URL. It's been working fine on one computer but when I copied the file over to my laptop it doesn't seem to do anything. I'm using localhost on both machines. They both run mac osx 10.6 with the bundled apache and php and the latest version of mysql. Everything works fine, it's just the .htaccess that doesn't do what it should. Is there any setting that I might have changed on my first machine and forgotten about?!
EDIT:
I'm wondering if there is something wrong with my CI setup now. If I load the base_url ie http://localhost/~User/project/
then it loads perfectly, adding the index.php.
My config file has
$config['index_page'] = '';
However, as a test I returned this value to 'index.php'. When I loaded the base_url after this it returned: http://localhost/~User/project/index.php/index.php/controller/method
Does this suggest anything to anybody?
SOLVED:
I added a new directory command to my httpd.conf file which targeted the specific site I was working on. Seems to be happy now, but not a very satisfactory way of dealing with the problem if I have several codeigniter sites in my web root.
With just a shot in the dark do you have mod_rewrite installed on both?
If your on Ubuntu, you need to edit /etc/apache2/sites-available/default.
sudo vim /etc/apache2/sites-available/default
Where you see lines that say AllowOverride change it to say:
AllowOverride All
You may also need to enable mod rewrite:
sudo a2enmod rewrite
Then, restart the Apache server
sudo /etc/init.d/apache2 restart
Are you sure you have changed the name of the root folder?
Here is what I do:
I put this on my root folder:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /rootFolder/index.php/$1 [L]
and in the path you replace "rootFoldel" with the name you are using.
hope that helps!
maybe you changed the path relative to the server root. it can breaks .htaccess and may be solved with a RewriteBase /path/to/folder/ statement
edit
since the problem not seems to be this one above, you could also check the error.log file in the apache folder (probably in the logs folder). it may have your answers and it can tell you if the .htaccess is getting parsed wrong or not parsed at all.