TheServant 1,168
Recognized Expert Top Contributor
Hi all,
I am trying to do something in CI which I cannot find any documentation for. I have set up my .htaccess so that if a file does not exist, and no controller/function is called it goes to the home page, but what I want is this:
Instead of http://mysite.com/controller/function/variable
I just use http://mysite.com/variable and it simply uses the default controller and index function.
The reason is, I am creating a CMS where pages will be retrieved like:
http://mysite.com/page/display/home
But I would much prefer:
http://mysite.com/home
http://mysite.com/contact
http://mysite.com/about
Anyone done this or know how to?
7 8319 Dormilich 8,658
Recognized Expert Moderator Expert
basicly something like this - RewriteRule ^([a-z])$ page/display/$1
you might add your personal constraints, though.
TheServant 1,168
Recognized Expert Top Contributor
I have been trying to do something like that, however my mod rewrite skills are a bit behind. I have this: - RewriteEngine On
-
RewriteRule ^(application) - [F,L]
-
RewriteCond %{REQUEST_FILENAME} !-f
-
RewriteCond %{REQUEST_FILENAME} !-d
-
RewriteRule ^(.*)$ index.php/page/index/$0 [PT, L]
Just checks if the file/directory exists, if not, then it should redirect to mysite.com/index.php/page/index/page_requested but it doesn't and I get a 500 error. Any help?
Dormilich 8,658
Recognized Expert Moderator Expert
don’t know too much mod_rewrite myself…
a) check the syntax ( manual)
b) check if you are allowed to use mod_rewrite. wrap the code in - <IfModule mod_rewrite.c>
-
</IfModule>
c) use a RewriteBase
d) (has nothing to do with the error) check for a / in the variable string (i.e. use a different RegEx)
TheServant 1,168
Recognized Expert Top Contributor
Well I don't know how to do this. I have realized that my removal of 'index.php/' with the following in my htaccess is not working: - RewriteEngine On
-
RewriteRule ^(application|system) - [F,L]
-
RewriteCond %{REQUEST_FILENAME} !-f
-
RewriteCond %{REQUEST_FILENAME} !-d
-
RewriteRule (.*) index.php/$0 [PT,L]
Yes I have already changed my config file so that $config['index_page'] = "";
Anyone solved a similar problem?
TheServant 1,168
Recognized Expert Top Contributor
SOLVED!!! I changed this in my config: - $config['uri_protocol'] = "AUTO";
~to~ - $config['uri_protocol'] = "ORIG_PATH_INFO";
Don't know what it does, but it works!
------------------------------------------------------
Edit:
I have just changed it back to AUTO as I found it stuffs up the search engine friendly URL's, and found another solution. htaccess was changed to include a "?" like so: - RewriteRule (.*) index.php?/$0 [PT,L]
Markus 6,050
Recognized Expert Expert
CI has this functionality built in: routing. In your config/routes.php file, try some thing like this: -
$route['(a-z+)/?'] = "page/display/$1";
-
TheServant 1,168
Recognized Expert Top Contributor
Ha! Nice work Markus, I was trying to get that to work before with no luck, but tried a little harder and voila!
I have another small problem though... Now none of my error pages work:
The page you requested, 403_shtml, could not be found. <-- This is my error display message.
I have realised that if I run everything through my other function, these pages won't work. Any ideas?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Fritz Bosch |
last post by:
We are in the process of refactoring our GUI-based test application
for radio equipment and are rewriting a significant part in Python.
The new architecture will substantially be based on the
model-view-controller pattern, as follows:
User Input
|
v
+-------------+ service request service request +-------------+
|
by: Stan |
last post by:
I want to make two pages interact through a controller.
1. Page A has a grid and Add button.
2. When Add button is clicked Page B pops up.
3. User enters information and clicks Save
4. Information is saved in database
5. User goes back to Page A which gets new data from database and displays
one more row.
So, the event handler for Add button on Page A might look like:
|
by: Andy Fish |
last post by:
Hi,
I have been thinking about the design of a large ASP.NET app and I've read
people have a lot of trouble implementing front controller, especially with
postbacks, so I don't feel comfortable going down that route at the moment.
The main proplem with the page controller pattern seeems to be related to
the fact that inheritance is used to implement different types of behaviour
and this will lead to large complex class hierarchies....
|
by: Griff |
last post by:
Two questions really, the first one "conceptual" and the other more involved
with design:
1 - There are two schools of thought where I work on the role of the
"controller" task.
The first is that the business object will provide the business rules and
that the controller will implement the rules and then pass the result set to
the view (i.e. do most of the grunt work).
|
by: uspensky |
last post by:
We are trying to setup a system to system failover cluster using two
nodes (x346) which each have a single hba running to seperate
controllers on the DS400.
For full redundnancy, IBM recommends dual path from each node but we
dont need that. The current setup has two completly seperate paths. hba
on node 1 to controller A on DS400 and hba on node 2 to controller B.
If i take a controller offline, failover works fine to jumo to other...
| |
by: Gerry Vandermaesen |
last post by:
Hi,
I was looking into CodeIgniter, and encountered the following problem:
In codeigniter, you could create a new controller like this:
---
class People extends Controller {
function index() { ... }
|
by: surfivor |
last post by:
I am doing some preliminary research as we are slated to do a project
with wordpress. I looked at the wordpress code and realized why I like
MVC so much (Rails) because the code mixed in with the rendering
looked like a mess to me. I'm not at all sure exactly what we will be
doing on the project as the details haven''t been discussed yet.
I found that the Wordpress API doesn't look well documented. I set up
wordress and created some blog...
|
by: Robertsonjay |
last post by:
In mvc you separate view from controller. How do you do that in C#?
Many people define an interface for a controller but isn't controller is specific to a form(gui) which all controller contains is handle events from gui controls(button, treeviews, textboxes etc..) which you don't know until you code the form.
So is there a point in having an interface for a controller where that controller is tightly tied to a specific form.
Having...
|
by: TheServant |
last post by:
I have recently (today) started doing something worthwhile on CodeIgniter, which is fantastic BTW. I have a problem and I can't figure out what is going wrong. I will post what I have now, but this has been changed so much in the past hour, it hardly reflects my efforts!
Control Call
$data->settings = $this->settings->get_settings();
Model Function
function get_settings()
{
$query = $this->db->get('settings');
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |