creating admin folder inside CodeIgniter App - codeigniter

I have the front end fully working in a codeIgniter application. Now, I have to create admin as well. So, How would I create the admin section creating a new directory. Without interrupting codeigniter directory structure.
localhost/myapp/admin

CodeIgniter already supports 1 subfolder level within the controllers folder. So within /applications/controllers/ you can just add /applications/controllers/admin/ and it will work fine.

you could omit it out via .htaccess so that the directory actually works like a directory rather than how its initially developed to work.
RewriteEngine on
RewriteCond $1 !^(index\.php|admin|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
what this does is turn on apache modrewrite then tells apache any calls to index.php, robots.txt or yourdomain.com/admin/ (and any sub-folders/files within) treat as you would normally without codeigniter mucking up the works. Also this will remove the required index.php from the URL you will be able to link to your site like
mydomain.com/home/
instead of mydomain.com/index.php/home/

There's an explanation about that in CI User Guide: Managing your Applications

Related

laravel external folder definition

My folders structure like this: app, bootstrap, public, vendor
But, I want to create another folder in there and put some php files (irrelevant with laravel).
For example wordpress.
i.e.
I have a web site with laravel and I want a wordpress blog in subfolder to.
I created folder names like "blog". But when I access domain.com/blog laravel presents an error.
I need to tell laravel, blog folder is not yours.
How can I do that?
I made like this:
RewriteEngine On
RewriteCond $1 !^(chat)
and it's work
RewriteEngine On
RewriteRule ^(blog)($|/) - [L]

laravel 5 removing public from url not working on WAMP

Many people post that following htaccess works for removing "public" from url. But i am working on WAMP and this is not working:
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
This shows following Error message from Laravel framework:
Sorry, the page you are looking for could not be found. 1/1 NotFoundHttpException in RouteCollection.php line 161:
There are other methods to remove "public" from url but I want to understand why this method is not working on my side which people followed frequently in their posts. my url is : http://localhost/laravel/ (directory: d:/wamp/www/laravel)
Can any one help me to understand why this popular method is not working on my side? Is their any issue in Laravel internal routing as I think my htaccess is working properly?
Thanks a lot in Advance.
I am sorry this is not exactly what you wanted but... Instead of rewriting the path, go to your Apache config and change your directory so it includes /public as well. That way you will get rid of the now necessary public from the URL. I know it is not an answer to your question, so please do not downvote. Nevertheless, it should solve your problem.
Your router is not picking up the redirected path because your laravel installation is a subdirectory within your webserver and the RewriteRule ^(.*)$ is picking up the whole path which includes /laravel. This is being appended to public/ because it's captured in $1.
The simplest case for you may be to alter the RewriteRule to not capture the laravel directory.
eg:
ReqriteRule ^laravel/(.*)$ public/$1 [L]
You may or may not need a forward slash ^/laravel/(.*)$ ...
Alternatively, (and more correctly) you should setup a virtual host within your apache configuration to serve the laravel application in the root of a virtual host (as it's designed) or you might be better off in the long run using Laravel Homestead as a preconfigured development environment.

how to redirect a link in my website to an external link?

I have provided a link from my web site in my andoird app which is:
www.mysite.com/support
And i want this link to be redirected to:
www.anothersite.com
i have already tried com_redirect and entered support as source and http://ww.anothersite.com but i dont get any redirects and i get 404 error.
I am running Joomla 3.x and i want to know how i can do this with URL rewrites and no external components.
It seems not possible to do it within the Joomla backend (i tried many combination of menu items and the redirect module).
For sure you can write your redirect directly in your .htaccess (if you are using it) like this:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^support/?$ http://www.anothersite.com/ [R=301,NC,L] # Permanent Move
or
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^support/?$ http://www.anothersite.com [R,NC,L] # Temporary Move
More info about URL rewriting and .htaccess are here: http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

mod rewrite all url's except includes (js/css/img/some php)

What I want is a Wordpress type of URL rewrite.
What I have now is:
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ rewrite.php?data=$1 [L,QSA]
This almost works rewriting everything except existing files (css,js etc files are not rewritten as expected).
The problems I have with this are:
.css, .js, Image and PHP files are also accessible by entering their file name. eg.: domain.com/style.css will be accessible by anyone.
I want some existing files(only php right now) to be redirected anyway. eg.: domain.com/movies.php should redirect to rewrite.php(include 404.php) and domain.com/movies or domain.com/movies/ would include movies.php page.
Ideally I would also be able to change user entered URL from domain.com/movies to domain.com/movies/ for consistency more than anything else.
I want to keep .htaccess to a bare minimum. Does wordpress rewrite everything including .css files?
What I want:
Some php files to redirect others not. eg: includes/func.inc.php
should not be accessible to the users, while movies.php should be
accessible but ONLY from this url domain.com/movies/
(not essential)
Change url to canonical url eg: domain.com/movies to
domain.com/movies/ (some resources on how to achieve this would be
nice). Note: domain.com/movies url should still work but appear with
a slash at the end either via rewrite or maybe by just adding a
slash with javasript (faster?)
Make .css/.js files inaccessible by the user. eg: domain.com/style.css should redirect the user to a 404 page

How to have an exception to URL routing in CodeIgniter

I have some legacy code that needs to be used in a new application. I would like to write the new application in CodeIgniter, but I still need to have some way of accessing the old code. what I would like to do is have an exception in the routing so that any url that has the format of example.com/old_stuff/* goes to an old_stuff folder, and acts as a regular, un-routed applications, while any other url such as example.com/new_stuff would route to a new_stuff controller, for example. So essentially what I want it to have URLs behave as they usually would in CodeIgniter, with the exception of any that start with one certain string.
What's the best way to accomplish this?
place codeigniter at your web root, and have your folder old_stuff in the web root also.
then use .htaccess with these rules (assuming you have mod_rewrite)
RewriteEngine on
RewriteCond $1 !^(index\.php|images|old_stuff|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
then, a uri beginning with old_stuff will just serve up the content bypassing codeigniter.

Resources