I have a URL
http://localhost/himalaya/webmanager/recentUpdate/index/edit-recent-update-1
but I want it to make the URL like this:
http://localhost/himalaya/webmanager/recentUpdate/edit-recent-update-1.
The controller name is recentUpdate and method name is index. My question is how can I remove index method name from URL in codeigniter framework?
Hi First you just read the what is index.php work in codeigniter.
https://ellislab.com/codeigniter/user-guide/general/urls.html
For remove the index then you write routing rule in .htaccess file.
above the application folder
RewriteEngine On
RewriteBase /project_name/
RewriteRule ^(.*)$ index.php?/$1 [L]
add .htaccess file in your project.
Add code in it.
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Related
I have worked on a website which was has two domain names.It got linked to one of them on one server.On trying the same on another server for a different domain the website gets linked and opens but it is just able to access the default controller.Anything I try other then the default controller it shows page not found.
there is issue with your .htacces file
just try
your.domain.com/index.php/contorller_name/function
if it works then replace your .htaccc file at main folder with this.
RewriteEngine On
RewriteBase /your_project_path
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]
Hi I am trying to use CodeIgniter A3M.
I am trying to view the manage users and manage permission etc but keeps on saying error 404 I am the admin I have just created an account for my self.
This seems to be a problem with your CodeIgniter setup. All the links in A3M are already assumes that you have taken steps to remove the index.php from the path using .htaccess. You can read in the user guide on how to do that. In general you should have this in your .htaccess file in the root:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Also check that you have all other settings set correctly according to A3M.
I think you must code .htacess file like this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Its working for me
My code .htacess
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteCond $1!^(index\.php|resource|system|user_guide|bootstrap|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php?/$1 [L]
I am trying to redirect url in CodeIgniter framework with www.hostname.com/crm/some/url to www.hostname.com/index.php?/some/url
I wrote following rule in my .htacess
RewriteEngine on
RewriteRule ^crm(.*)$ index.php?/$1 [L]
When i try this in browser, i get page not found 404 from codeIngnitor. But if add [R] flag in the redirect rules, it works proper and i could see the new url as expected after the change.
I tried apache rewrite log. Everything looks proper. I have no what URL the CodeIgniter frame sees after rewrite. Any help is appreciated.
Is there a reason you're not using the typical Codeigniter .htaccess?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
You can follow this, Do this code copy and paste in your .htaccess file. I think
it will help you.
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|uploads|themes|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
Here is my .htaccess for simple url rewriting for any MVC architecture.
Options +FollowSymlinks
RewriteEngine On
RewriteBase /personal/site/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Every thing is working only one exception rises. On the root where index.php exists i created a file generator.js, i also do have a controller named generator.
So for a request, http://localhost/personal/site/generator/css,
it must rewrite it to http://localhost/personal/site/index.php/generator/css
But it is rewriting it to http://localhost/personal/site/generator.js/css
How to resolve this scenario?
Turn off multiviews.
Options -MultiViews
My .htaccess file has the following code:
RewriteEngine on
RewriteRule ^/?(.*)$ index.php?domain=$1 [L]
I'm trying to get domain names as variables from URLs like:
hxxp://www.example.com/www.domain.name or
hxxp://www.example.com/subdomain.domain.name or
hxxp://www.example.com/domain.name
but with $_GET['domain'] my variable is always 'index.php' and not the domain names.
With hxxp://www.example.com/domain/www.domain.name and .htaccess code
RewriteEngine on
RewriteRule ^domain/?(.*)$ index.php?url=$1 [L]
everything is OK, but I would like to remove the 'domain/' part from the URLs.
I've searched for this, but couldn't find anything. Could someone please help me with this?
something like
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?domain=$1 [L]
in this case $1 will be:
http://site/www.example.com $1 = www.example.com
http://site/www.example.com/xyz $1 = www.example.com/xyz
Try this rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[^/.](\.[^/]+)+$ index.php?domain=$0 [L]
This will rewrite any request with a URL path that contains at least one dot (foo.bar, foo.bar.baz, etc.) to your index.php.