php - 404 Page Not Found codeigniter url - php

my framework is codeigniter and my site works fine.
example :
www.example.com/
now,I have copied all my codeigniter's folders to another dir like this:
www.example.com/test
now my urls:
www.example.com/profile //works fine
www.example.com/test/profile //not work
I get 404 page not found .
I changed base_url to :
$config['base_url'] = 'http://www.example.com/test';
where is my wrong?

please have a look at your .htaccess file. Because it'll be in the RewriteBase condition in there. Check it and tell what You found.

Codeigniter does not support multiple subdirectory levels in your controllers
But still you can extend it.
You might have to extend Router Class

Do you still have all CodeIgniter files in your main directory?
If yes, then you must remove them or you can create SUBDOMAIN to solve the issue.
Note: Codeigniter don't support multiple subdirectory levels in your controllers.
If no, then you must look for your .htaccess file, it'll be the RewriteBase condition in there.

Related

Symfony : How to disable the routing system on other folders

I'm using Symfony for my new website but I have a problem : I can't seem to be able to access the forum anymore.
These are my folders on my server:
I found a solution but it doesn't work well - in my .htaccess (location: /website/web/) I put this:
RewriteRule ^(ddl|phpmyadmin|forum)($|/) - [L]
With SymLinks for forum, ddl and phpmyadmin in /website/web/
With this solution, I can see the forum but I can't access to the upload system because of the URL : http://www.website.fr/forum/upload/
Is there a solution to access http://www.website.fr/fichiers/ or http://www.website.fr/forum/ without the routing system of Symfony?
Ok... I just had to add index.php at the end of the URL and it works now. But this system with SymLinks is weird.

I have changed my old website from asp.net to php and i need to redirect the pages using web.config

This is my current web.config file where i am trying to redirect the page of www.abadbuilders.com/projects/spice-town to www.abadbuilders.com/project. But what happens actually is that it doesn't redirect to the particular page instead it gets an 404 page not found error. Can anyone helps me on this issue.
Thanks
web.config is the configuration file for ASP.net it wont work with PHP.
If you are using an Apache server for your website then you can .htaccess file to set the URL redirection, else you can code in the PHP code itself using header('redirect', 'http://the.url/you/wish/');
For your reference
httpd URL Rewriting Guide
PHP: Header
For redirecting in CodeIgniter you can use Routes configuration.
You need to edit the file application/config/routes.php
You need to add after this line of code
$route['404_override'] = '';
Your rewrite code will be like this
$route['projects/(:any)'] = 'project';
I hope you have a controller Project that have functions to display projects.

mod_rewrite and routing to code igniter

I have been using code igniter as a subdirectory of a site and have several instances of if on one server. Each instance is considered a separate application, but all under the same domain name. I am looking to enable a slightly different URL structure though and have turned to mod_rewrite to help me out.
The page is reachable at http://localhost/test but I want to rewrite that URL to appear as http://localhost/en-US/test.
The problem is I keep getting a code igniter (CI) 404. I can confirm the mod_rewrite is reaching the CI index.php, but CI is failing to deliver the correct page. Here's and example setup:
1) Download a new instance of CI and place it in a subdirectory in the site root. Name the CI folder "test". It should be reachable now on a local server at http://localhost/test and you should see the default welcome view.
2) Create a .htaccess file in the server's root web directory. DO NOT place it in the CI "test" directory. Add the following lines to it.
RewriteEngine On
RewriteBase /
RewriteRule ^en-US/test/?$ test/index.php [NC,L]
From my understanding of mod_rewrite, this should allow the URL http://localhost/en-US/test to render what is located at http://localhost/test. It doesn't though. I just get the CI version of a 404. I need help figuring out how to resolve this.
Hmm your question made me install CodeIgnoter and read its routing :)
Anyway have your DocumentRoot/.htaccess like this:
RewriteEngine On
RewriteBase /
RewriteRule ^en-US/(test)/(.*)$ $1/$2 [NC,L]
Then replace this line in your /test/application/config/config.php`:
$config['uri_protocol'] = 'PATH_INFO';
It is by default set to:
$config['uri_protocol'] = 'AUTO';
After this you can open this URL: http://domain.comen-US/test/ to load CI home page in /test/ dir.
You should check out routing. Place this statement in your config/routes.php file AFTER the reserved routs.
$route['test'] = "en-US/test";
You can forget about htaccess when you have Codeigniter (most of the times).

Laravel home page gives 404 but index.php works

I'm creating a custom cms in a subfolder of my site. I installed a fresh copy of laravel at www.mysite.com/cms/ <-- application, bundles, public, etc are there.
I can not make a virtual host due to shared hosting but I managed to remove the need for the /public to be in the url by putting
RewriteCond %{REQUEST_URI} !^/cms/public/.*$
RewriteRule ^(.*)$ /cms/public/$1 [L]
in the .htaccess file in my cms folder.
The thing is, clean urls works www.mysite.com/cms/public/ shows the Laravel starter page. But www.mysite.com/cms/ gives me a 404 not found error and www.mysite.com/cms/index.php shows the Laravel starter page.
I have set the url array element in application.php to
'url' => 'http://www.mysite.com/cms/',
and the index element to
'index' => '',
Has anyone come across this issue?
To use laravel on shared hosting, I would recommend to try this.
By the way, in your .htaccess, you are just redirecting to all non-exist request query to index.php in public directory. Because of the fact that, you should access with url.com/public.
Perhaps if you were to upload the contents of your public folder into /cms, and the other folders into /cms_system, you could change the paths.php file to reflect this?
So, you'd have this:
/cms
(contents of the public folder, with .htaccess)
/cms_system
/application
/bundles
/laravel
/storage
(etc)
Your paths would then look like this:
$paths['sys'] = 'system';
$paths['bundle'] = 'bundles';
$paths['app'] = 'application';
$paths['storage'] = 'storage';
$paths['public'] = '../cms';
I haven't tested this yet, but it should work. Please let me know if there are any problems with it, and will see what can be changed accordingly.

Can I use Code Igniter with Concrete5?

I am building a site that will (obvisouly) have a front end public portion that I want to drive with Concrete5, but then it will also have a members section that I would like to build with Code Igniter.
Does anyone have any idea how I could do that?
I guess I could just throw the Code Igniter code into a sub directory, but would I run into any issues with that?
i can't see why not.
As you suggested a separate folder on the site would be one solution.
(you might have to tweak the .htaccess file (if you are using one) to ignore the other cms/framework
Another solution would be to have separate subdomains,
eg example.com and members.example.com
The answer, since the OP hasn't posted it, is to change the .htaccess rule:
RewriteBase /
to:
RewriteBase /foo/
where foo is your subdirectory that the index.php and CI reside. This .htaccess should also be in the same folder as the CI index.php. Works like a charm. Also don't forget to add the subdirectory to the base_url config setting.
I ended up using a sub directory for Code Igniter. I had to change the .htaccess file and Mod_Rewrite rules for apache in order for the Code Igniter "pretty" URLs to work correctly.
I will post the code later if I remember.

Categories