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 8282
basicly something like this - RewriteRule ^([a-z])$ page/display/$1
you might add your personal constraints, though.
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?
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)
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?
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]
CI has this functionality built in: routing. In your config/routes.php file, try some thing like this: -
$route['(a-z+)/?'] = "page/display/$1";
-
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...
|
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....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |