I'm working on a CodeIgniter application that was previously developed.
The issue that I'm getting is a page not found and I have installed on wamp.
Here is the .htaccess file that I'm currently using for the app (not the wamp one).
# Turn on URL rewriting
RewriteEngine On
# Allow these directories and files to be displayed directly:
RewriteRule ^(index\.php|css|js|fonts|images|uploads|audio) - [PT,L]
# Rewrite all other URLs to index.php/URL
# RewriteRule .* index.php?/$0 [PT,L,QSA]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
How do I go about fixing the 404 issue? Would I change the wamp .htaccess file?
Thank you,
Kevin Davis
# Turn on URL rewriting
RewriteEngine On
RewriteBase /FOLDERNAME/ #Add your foldername in place of FOLDERNAME
# Allow these directories and files to be displayed directly:
RewriteRule ^(index\.php|css|js|fonts|images|uploads|audio) - [PT,L]
# Rewrite all other URLs to index.php/URL
# RewriteRule .* index.php?/$0 [PT,L,QSA]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Try using below .htacccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hope this can help you.
Related
I'm developing with WampServer and tried to remove index.php from CodeIgniter urls. Added these lines to .htaccess file as I saw in ellislab website:
https://www.codeigniter.com/user_guide/general/urls.html
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
This is the root of my website:
http://localhost/job/
But now when I want to navigate urls like http://localhost/job/seeker I see the Wampserver config page that is on http://localhost/.
What can I do?
Thanks
RewriteEngine on
RewriteBase /job
RewriteCond $1 !^(index\.php|images|table-images|robots\.txt|styles|js|uploads)
RewriteRule ^(.*)$ index.php/$1 [L]
and set in application/config/config.php
$config['base_url'] = 'http://127.0.0.1:8000/job/';
$config['index_page'] = 'index.php';
Try this:
RewriteEngine On
RewriteBase /projects/hc/homecare/trunk/homecare
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
RewriteRule ^(.*)$ /projects/hc/homecare/trunk/homecare/index.php?/$1 [L]
The following code is taken from http://www.farinspace.com/codeigniter-htaccess-file/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
### 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]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301]
# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://domain.tld/$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]
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
Ensure the .htaccess file is named correctly and in the same directory as your index.php file and that mod_rewrite is enabled in Apache on your server stack.
Also ensure you set your Code Igniter config correctly again, according to the same link, edit your config file.
$config['index_page'] = "index.php";
to
$config['index_page'] = "";
Also, please use search. This question pops up quite a bit in many places with answers every where.
it happens in wamp server try this
RewriteEngine On
RewriteBase /name_of_your_project
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
**
Remove index.php and redirect anyurl.com to www.anyurl.com in codeigniter
**
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s on(s)|offs()
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]
I tried to get rid of "index.php" in url using the following rewrite code.but it's not working
please help me to fix this bug
# Development
RewriteEngine On
RewriteBase /mvcTestApp/blog/ciBlog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|scripts|styles|vendor|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
In .htaccess file, add the following.
#Rewrite index.php
#Start using rewrite engine
RewriteEngine On
#Rewrite condition
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#Whenever index.php is there in the url, it will rewrite to / automatically
RewriteRule .* index.php/$0 [PT,L]
Check this link for more detail: http://subhra.me/remove-index-php-urls-codeigniter/
This htaccess is working for me.Try this.
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]
Use this rule
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
missing "/" before "index.php" in last rule
or refer URL
http://ellislab.com/codeigniter/user-guide/general/urls.html
Here's my suite of rewrite rules for CodeIgniter. Please read the inline comments:
## Rewrite rules
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Remove the "index.php" part of URI
# Remove access to "codeigniter" and "data" folders
RewriteCond %{REQUEST_URI} ^(codeigniter|data).*
RewriteRule ^(.*)$ /index.php?/$1 [L]
# Block access to "hidden" directories whose names begin with
# a period. e.g. .git, .svn
RewriteCond %{SCRIPT_FILENAME} -d
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
# WWW redirect
RewriteCond %{HTTP_HOST} ^(?!www\.).*
RewriteCond %{HTTP_HOST} ^(?!dev\.).*
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,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 the root index.php.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
This is what is in my .htaccess file right now.
Now I want to eliminate the index.php in my url. How do i do this?
I have tried several possibilities from this website but either i get a 500 internal error or nothing changes at all.
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
The following code will rewrite index.php to index
RewriteEngine on
RewriteRule ^index index.php
Try if this works
Options +FollowSymLinks -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I developed an application in a subfolder of my website and it worked fine.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.*)$ /app/index.php/$1 [L]
</IfModule>
This file was working fine so and index.php was not required to navigate within the application. Now I moved the application to root of website and changes the last line to
RewriteRule ^(.*)$ index.php/$1 [L]
Now I have start getting Internal Server Error 500. I am not sure that it is something I have done or the .htacces is required to be configured differently. It might be an issue with host too, but I want to exhaust my options first.
Any help will be appreciated. Thanks in advance.
if you in root of hosting you just need
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
if you site in folder /foo you need:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /foo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.*)$ /foo/index.php/$1 [L]
</IfModule>
if still not working try this, for me it works all over:
RewriteEngine On
RewriteBase /foo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /foo/index.php/$1 [L]
I'm using my htaccess file with mod_rewrite to create clean urls like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
I would also like to force the site to have the 'www' subdomain and most importunately add a trailing slash if the url doesn't have one.
I am an absolute noob with mod_rewrite and I've tried accomplishing this on my own by combining other code I found on google (sad I know), but I always end up with a 500 error.
Here's the code I found for force www:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC]
RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L]
</IfModule>
Thanks for your help.
Try separating out the www and the trailing slash check. This is tested and hopefully working for you. You didn't say if you're running placing at domain root or in a subdirectory - usually good info when asking for help with htaccess.
RewriteEngine On
# Assuming you're running at domain root. Change to working directory if needed.
RewriteBase /
#
# www check
# If you're running in a subdirectory, then you'll need to add that in
# to the redirected url (http://www.mydomain.com/subdirectory/$1
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
#
# Trailing slash check
# Don't fix direct file links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L,R=301]
#
# Finally, forward everything to your front-controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [QSA,L]
To debug, comment out the individual sections and see what is/isn't working.
Use this and forgot your problems ;)
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*?)/*$ http://%1/$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://your-domain.ru/$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>