My project (codeigniter) runs on Windows 7
Now my URL looks like:
http://dev.something.com/index.php/reports
and I want:
http://dev.something.com/reports
I try to hide index.php from my URL in order to get access to controller.
From this link I took .htaccess
So my .htaccess looks like:
Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|app|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
But this change didn't help me.
Important:
I cleared all data from .htaccess but nothing happened. Sounds like Codeigniter don't see .htaccess
.htaccess stays under my root project a.e.:
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\someprog_dev\.htaccess
[EDIT 1]
The same project works fine on Linux so its not codeigniter configuration problem
[EDIT 2]
I change .htaccess to be sure that codeigniter uses .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blogna/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Nothing happens. Works with index.php but not without one.
[EDIT 3]
My httpd.conf looks like:
....
LoadModule rewrite_module modules/mod_rewrite.so
...
LoadModule php5_module "c:/php/php5apache2_2.dll"
<IfModule php5_module>
AddType application/x-httpd-php .php
PHPIniDir c:/php/
DirectoryIndex index.php index.html
</IfModule>
Did I miss something? any suggestions
This never worked for me as well with codeigniter.. but the following did:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
Replace the paths if necessary
Good reference: http://softkube.com/blog/url-rewriting-for-codeigniter/
Try these
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
My .htaccess is as simple as
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt|js|files|icons|images)
RewriteRule ^(.*)$ /pathtoapp/index.php?/$1 [L]
and works perfectly. But you need to have everything in CI's config files properly set, and the rule must match your $config['base_url'].
So if you have
$config['base_url'] = 'http://localhost/myapp/';
You have to put
RewriteRule ^(.*)$ /myapp/index.php?/$1 [L]
Try this htaccess.It's working well.
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]
Change the index.php to whatever your main controller.
Related
I'm trying to build a shopping cart using PHP & MySQL. Right now I'm in the process of creating product-detail pages. So this is how I set up my htaccess (located in the root folder):
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
My problem is I can only access a certain page if index.php is included. For example, http://localhost/thegamingplace/products/details/1 displays a "Not Found" error, but http://localhost/thegamingplace/index.php/products/details/1 works.
Can someone take a look at my htaccess and tell me what I'm doing wrong?
Try this:
RewriteCond %{REQUEST_URI} !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ index.php/$1 [NC,L]
It works when tested at http://htaccess.mwl.be/
If it doesn't work make sure you have mod_rewrite installed and enabled.
I'm having issues with .htaccess RewriteRule. all I'm trying to do is
rewrite this url - www.example.com/public/?q=admin
to - www.example.com/public/admin
but now when I go to this url www.example.com/public/admin it says not found.
but this url is working ww.example.com/public/?q=admin
here is my .htaccess code
Options All -Indexes
<FilesMatch "(config|.+\.html)\.php">
deny from all
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !\.(bmp|cgi|css|flv|gif|ico|jpe?g|js|png|swf|xml)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) ?q=$1&%1 [L,QSA]
</IfModule>
Does anyone know to help?
UPDATE
This script installed inside a subdomain and a sub folder
like this
http://subdomain.maindomain.com/comingsoon/
coming soon is the root folder
http://subdomain.maindomain.com/comingsoon/public is another folder where placed .htaccess file.
I'm using mini php framwork called Swiftlet
https://github.com/AliasIO/Swiftlet
You can use this rule in your .htaccess for your required url.
RewriteRule ^public/(.*)$ public?q=$1 [L,QSA]
UPDATE 1:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.domain.com
RewriteRule ^public/(.*)$ http://subdomain.domain.com/comingsoon/public?q=$1 [L,NC,QSA]
Ok, so after your update, try this :
RewriteBase /comingsoon/public
RewriteRule ^(.*)$ /?q=$1 [L,QSA]
I have set WAMP up and running without too much hassle. But thing is I could not skip past index.php in my URL (localhost/index.php/login is working but localhost/login is not working).
Anyway my project is based on CI framework and I was using vagrant previously for hosting same project and which is working perfectly for this case. I have checked that the rewrite_module on for Apache and here it is my .htaccess file.
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Please help me out from here.
First of all go in your project myproject-application->config.php
replace line no. 29
From
$config['index_page'] = 'index.php';
To
$config['index_page'] = '';
Then add .htaccess file on your root folder.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Try this .htaccess file code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
I'm using MAMP and CodeIgniter.
The root of my website is: /Users/Roy/Websites/CodeIgniter-3.0.2
In the Websites folder I also have some other project but I don't think that matters. Here is the apache httpd.conf file: http://pastebin.com/Am0ew0C0
In my .htaccess file I'm using the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
the .htaccess file is located at: /Users/Roy/Websites/CodeIgniter-3.0.2/.htaccess
I have no idea why the mod_rewrite isn't working, it's supposed to eliminate the use of index.php in the url because the URL I have to use now is: http://localhost:8888/CodeIgniter-3.0.2/index.php/about
And I would like that to become: http://localhost:8888/CodeIgniter-3.0.2/about PHP version 5.6.10 is used. the .htaccess file is not being read by apache, that is the problem here, how to fix it?
Problem solved, there is no need to mess with the httpd.conf with MAMP installed. Simply get CodeIgniter and place it in the htdocs folder inside MAMP. After that create a .htaccess file inside the CodeIgniter folder (not the application folder inside there) and use the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Now you have clean URL's and no longer need to use /index.php/about but can just do /about.
It maybe from the fact of what you set your document root to /Users/Roy/Websites/ in your httpd.conf file. Personally I would use virtualhosts if you plan to have multiple websites so that each one can have it's own .conf and you can set the Document root specifically for each site.
Anyway, so right now your CodeIgniter-3.0.2 is a subfolder of Websites which is your document root. So most likely you're having a problem with the rewrite base.
If you have your files and .htaccess in the codeigniter folder, your .htaccess will need to look like this.
RewriteEngine On
RewriteBase /CodeIgniter-3.0.2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
You can use this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /Project_Name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
It look like file permission issue. check out the properties of your .htaccess file and change the permission.
The try with this code.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
for more try http://w3code.in/2015/09/how-to-remove-index-php-file-from-codeigniter-url
.htaccess could be very frustrating. take a lot at what really works
1.Your .htaccess should look like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /booking/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
2.Replace line 3 with the root directory name of your project, in my own case 'localhost/booking/'
3.Copy the .htaccess file from the application folder to the root directory. This means that you will now have to instances of .htaccess file in you entire project.
4.in your config.php , Base url should look like this in my own case
$config['base_url'] = 'http://localhost/booking/'
5.
$config['index_page'] = '';
6.
$config['uri_protocol'] = 'REQUEST_URI';
7. turn on Mod-rewrite in your httpd.conf file by removing the # preceding this line
LoadModule rewrite_module modules/mod_rewrite.so
I hope this solves your problem
I'm using the following .htaccess file to rewrite the URL's without index.php:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
The site is uploaded on my VPS, and when I enter it on, let's say:
http://1.1.1.1/~admin/
it works fine. Now when I want to navigate through the website to for instance:
http://1.1.1.1/~admin/welcome
it gives me the following error message:
The requested URL /home/admin/public_html/index.php/welcome was not found on this server.
Now when I access the welcome controller with the index.php in the URL:
http://1.1.1.1/~admin/index.php/welcome
It works fine again. What is going wrong here?
I use this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
The "?" after index.php is required for godaddy. See this link: https://github.com/EllisLab/CodeIgniter/wiki/Godaddy-Installation-Tips
The path /welcome does not exist on the server, the rewrite should be something like:
RewriteRule ^(.*)$ index.php?$1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>
I wrote this: Trouble Shooting Codeigniter on localhost
http://garyjohnson53.wordpress.com/2013/10/31/trouble-shooting-codeigniter-on-localhost/
Its not a polished article, but it walks you through a few of the common things with codeigniter.
MVC URI segments
example.com/class/method/id/
your condif.php usually in application/config
your index.php
your .htacess
Alias and apache
etc.