Welcome Guest, Not a member yet? Register   Sign In
Newbie needs help
#1

[eluser]ecotypes[/eluser]
Hi -

I'm very new (I'm on my first site, third page!) and suspecting that I may have some routing or .htaccess problem.

I have not attempted to remove index.php from the URLs.

URLs without parameters work and I get where I want to go.

http://www.shirleydenton.com/index.php/plants/pindex

works

I printed out what is in the segments, it is correct. Segment 1 is plants. Secment 2 is pindex, Segment 3 is undefined, Segment 4 is undefined

I then try to use the URL to pass data in the segments

http://www.shirleydenton.com/index.php/p...ex/alpha/A

I get a 404 error.

Is this some type of routing problem? If so, I'm not understanding the myriad of posts on routing and .htaccess

I have no .htaccess file at this point -- do I need one to get this to function?
My site is on BlueHost

Thank you in advance.
#2

[eluser]umefarooq[/eluser]
hi just simply try some route in route.php file

Code:
$route['plant/pindex/(:any)/(:any)'] = "plant/pindex/$1/$2";
#3

[eluser]mddd[/eluser]
@ecotypes: As far as I can see, what you are doing is correct. A url like /plants/pindex/alpha/a should just work! Assuming you have a controller called Plants in you controllers folder, and that controller has a method (=function) called pindex. Anything after that should not give you a problem. It is okay to have extra information after the controller/method. A 404 error means that CodeIgniter could not find the controller with that name (Plants) or you have no method in that controller with the right name (pindex). Do you have any folders INSIDE your controllers folder? If you had a folder called Plants in there, that WOULD be a problem. Because CI can work with one level of folders INSIDE the controllers-folder. In that case, it would look for a controller called 'pindex' inside the 'plants' folder in your controllers-folder..

@umefarooq: I don't see that that makes a difference. You would be rewriting an address into exactly the same address. No change.
#4

[eluser]ecotypes[/eluser]
I do have the controller. And named as appropriate. So long as I don't add extra segments on the end, it works. Also isn't specific to one controller.

I thought possibly setting up .htaccess to eliminate the index.php might help. If doesn't. It does successfully eliminate the index.php, but I still can't get those last two segments recognized as data -- the site seems determined to load the entire URL. I've tried the previous suggestion on setting the route to no avail.

I just went through a battle with htaccess to get back to almost where I was (it now doesn't look like I get form parameters through either -- my login script is now failing and it worked before. I've tried going to the BlueHost form to see if there is an appropriate .htaccess script, but the forum seems to be down. It also might be that I'm actually in a subdirectory which happens to have its own domain name. I'm loading the .htaccess at the base of that subdirectory. But since I didn't have one at all before and the basics of this one appear to be working, I'm doubting that as the problem.

.htaccess

# Set the default handler.
DirectoryIndex index.php

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

### Canonicalize codeigniter URLs

# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]

# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.shirleydenton.com/$1 [L,R=301]

# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]

###

# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>

# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php

</IfModule>

In routes.php it seems to make absolutely no difference if add the suggestion made by the previous responder.


$route['default_controller'] = "welcome";
$route['scaffolding_trigger'] = "";

$route['admin'] = 'admin/home';

// For pages that stick parameters into the URL
$route['plants/pindex/(:any)/(:any)'] = "plants/pindex/$1/$2";
/* End of file routes.php */
/* Location: ./system/application/config/routes.php */

In config.php

I've tried all settings for
$config['uri_protocol'] =


Thanks in advance if you have any ideas!
#5

[eluser]ecotypes[/eluser]
Thank you mddd!

Your advice was right on target and worked. I got tangled up along the way with the .htaccess file. But having cleaned up that and used your insights on structure, I'm getting my arguments.




Theme © iAndrew 2016 - Forum software by © MyBB