I am working on codeigniter
when I used it on xampp server it worked pretty well with this Url
localhost.com/realestate/index.php?class/method/parameter
But when I put similar thing on godaddy host
Same Url segment is showing codeigniter 404 error
Add .htaccess for your folder. Here is some result Check it out all the links.
Host is Case-Sensitive so be careful with naming of Controller and model names as well
DirectoryIndex index.php index.html
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteBase /yourfoler/
RewriteCond $1 !^(index\.php|assets|install|update)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For godady Shared Hosting Server uncomment the line below
RewriteRule ^(.*)$ index.php?/$1 [L]
# Please comment this if you have uncommented the above
# RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]
</IfModule>
localhost.com/realestate/index.php?class/method/parameter instead of this you can localhost.com/realestate/class/method/parameterrun like this with this following htaacess
Related
I have a VPS Server (Debian 9) and I want to have clean url.
If I enter for example "examle.com/example", this pops up an error "Internal Server Error" instead of showing the page.
What do I need to do to make this mistake disappear and show the page?
That style of URL (domain.tld/resource/path) would need to be handled via mod_rewrite (with Apache) or a try_files configuration with Nginx. Which you use depends on which HTTP server you're running, of course. Unless you're explicitly setup Nginx, it's probably Apache.
Assuming Apache (httpd) is being used- The easiest method to manage this is via a .htaccess file in your document root (where your index.php file lives). You'll need to verify mod_rewrite is enabled in your httpd configuration (usually found at /etc/httpd/httpd.conf or broken out further in a subdirectory).
There are a lot of configuration options available to you via mod_rewrite. Here's an example of one that will translate all URLs that do not point to an actual directory or file (thus preserving your ability to serve static content directly from httpd) to index.php:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
You would need to parse the URL to determine what to do with it (it will be contained within $_SERVER['REQUEST_URI']. Be sure to reference the mod_rewrite documentation if you need to make changes to this configuration.
try this I hope its help you
create a .htaccess file in your html folder and write blow code in it.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
</IfModule>
or try below.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
and the last one is for trailing slash at the end. (only use codes as your needs only).
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
</IfModule>
more you can understand on
thanks.
I don't know why but all the time it shows me the error "500", even if I have empty .htaccess and basic files apache2.conf and 000-default.conf
The ERR_EMPTY_RESPONSE comes randomly on www.domain.com/ci_project
I have a shared hosting with multiple domain hosted on it. In the root folder of my hosting exists a .htaccess file. The code is as follows:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
And inside a folder there is a codeigniter site say ci_project. The htaccess is as follows
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
If I comment the htaccess file of the ci_project, www.domain.com/ci_project works fine without the random error But I need the htaccess file as it removes index.php from the url
Can anyone please tell how the issue can be resolved..
Try to open the pages in a browser other than Chrome.
If the issue (random error) is not appearing in other browsers then clear the browser cache of Chrome and then open the pages. This random error should disappear.
I would need some help, I have go-dady hosting and sub-domain. I also have simple HTML website that is included in codeigniter system. The problem is that main page works (http://new.bendcare.com), but all sub-pages doesn't work, i get error:
No input file specified.
My base url in set:
$config['base_url'] = 'http://new.bendcare.com';
My current .htaccess is:
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
# Mod Rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
I found that I should add #Mod Rewrite on godady hosting to work correctly, but not in my case.
What should I change to make codigniter work on godady hosting ? I have no problems on other hosting's.
Just add the ? sign after index.php in the .htaccess file :
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
And it would work !
I have done this lots of time. But than also I am stuck here again (in a different server) and can not figure out what is the issue.
Completed htaccess editing
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /glt.me/CI/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /glt.me/CI/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
rewrite module is enabled (as per customer care perons says)
Error :
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, cgiadmin#yourhostingaccount.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Test this case :
http://glt.me/CI/test
http://glt.me/CI/index.php/test
This is the simple way and it works fine for removing index.php from your url
RewriteEngine on
RewriteCond $1 !^(index\.php|uploads|css|js|lib|img|bootstrap|robots\.txt)
RewriteRule ^(.*)$ /manage/index.php/$1 [L]
instead of manage put your own application folder name.
Use following htaccess code to remove index.php from your codeigniter url
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]
Though your client confirmed the rewrite module is working, what don't you confirm it yourself, make a php file on the root of the project with the code below and try to browse the file.
<?php
if( !function_exists('apache_get_modules')){
echo 'Rewrite module not available';
}else{
if(in_array('mod_rewrite',apache_get_modules()))
echo 'Rewrite module enabled';
}
First check whether your apache is supporting mod_rewrite. If yes then add a .htaccess file. My codeigniter .htaccess file is:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
Finally in your config file, change your base_url, remove index.php from that if you have added.
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
RewriteRule ^pages/.*$ http://localhost/test/? [R=301,L]
I wanted to contribute here as I was having trouble myself. I'm using IIS5.1 for development only (Highly not recommended!)
1- Make sure that you config.php file has:
$config['index_page'] = '';
2- My app is not on the root folder, it's at localhost/CodeIgniter/. I updated config.php to:
$config['base_url'] = 'http://localhost/CodeIgniter/';
3- You need Mod-Rewrite capabilities. This is embedded with most servers, but IIS5.1 needs a separate tool. I used: IIS Mod-Rewrite by micronovae. It's free as long as you use it on localhost
I put the following code (Instead of CodeIgniter, put the name of the folder):
RewriteEngine on
RewriteCond $0 !^/CodeIgniter/(css|js|swf|images|system|tools|themes|index\.php) [NC]
RewriteRule ^/CodeIgniter/(.*)$ /CodeIgniter/index.php/$1 [L]
If your application is at the root, the code you should use would be simply:
RewriteEngine on
RewriteCond $0 !^(css|js|swf|images|system|tools|themes|index\.php) [NC]
RewriteRule ^(.*)$ index.php/$1 [L]
Hope it helps.
Only three steps are require to remove index.php from url in Codeigniter in WAMP environment.
1) Create .htacess file in parallel to application holder and just copy past the following code:
RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2) Change $config['index_page'] to blank in config.php in application folder as below:
$config['index_page'] = '';
3) Enable “rewrite_module” of apache.
Restart your apache and its done.
Details : http://sforsuresh.in/removing-index-php-from-url-of-codeigniter-in-wamp/
I've just uploaded my website from my local server (XAMPP). It was working locally, but for some reason the rewrite to add index.php to my SEF URL's is not working in my public server. This is what I've got right now:
# Avoid listing directory
Options -Indexes
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
# manage language segment
RewriteRule ^(es|en)/(.*) $2?lang=$1 [L]
# code that allows to get rid of index.php from URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
</IfModule>
These URL's work:
www.example.com
www.example.com/index.php/aboutme
while URL's like this generate a 500 error:
www.example.com/aboutme
Here's another combination of condition and rule I tried to solve the index.php removal:
RewriteCond $1 !^(index.php|css|img|scripts|ckeditor|robots.txt|sitemap.xml)
RewriteRule ^(.*)$ index.php/$1 [L]
But it generates a 500 error for any URL without index.php, including the root URL www.example.com
Could you help me fix this?
There seems to be a typo in your RewriteRule.
Try this:
RewriteCond $1 !^(index.php|css|img|scripts|ckeditor|robots.txt|sitemap.xml)
RewriteRule ^(.*)$ /index.php/$1 [L]
It works for us with Code Igniter. The only difference is the slash infront of index.php when compared to your second examples.