CodeIgniter Forums
URI Troubles - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: URI Troubles (/showthread.php?tid=17486)

Pages: 1 2


URI Troubles - El Forum - 04-06-2009

[eluser]stuffradio[/eluser]
For some reason, I get a lot of this message
Quote:The URI you submitted has disallowed characters.

and sometimes this message

Quote:Message: preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 19

The url is http://localhost/urls/register

htaccess file is

Code:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

index page is blank

Allowed characters:
Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

Routes
Code:
$route['default_controller'] = "followurl";
$route['followurl'] = "followurl";
$route['settings'] = "settings";
$route['urls'] = "urls";
$route['user'] = "user";
$route['scaffolding_trigger'] = "";
$route[':any'] = 'urls/getpage/$1';

What I want is, anytime I don't have any of those controllers in the routes page, it should redirect using the :any route. This is for a short url script I'm doing.


URI Troubles - El Forum - 04-06-2009

[eluser]xwero[/eluser]
you have a question mark in the last line of your .htaccess


URI Troubles - El Forum - 04-06-2009

[eluser]stuffradio[/eluser]
That fixed some of the problem (I copied and pasted that htaccess file)

The URL that I listed above still has the same problem though. Any thoughts?


URI Troubles - El Forum - 04-06-2009

[eluser]xwero[/eluser]
your any route is not fetched so $1 will not be undefined. you need to add parenthesis.


URI Troubles - El Forum - 04-06-2009

[eluser]stuffradio[/eluser]
Can you show me?


URI Troubles - El Forum - 04-06-2009

[eluser]xwero[/eluser]
(:any)


URI Troubles - El Forum - 04-06-2009

[eluser]stuffradio[/eluser]
When I have this line uncommented
Code:
$route['(:any)'] = 'urls/getpage/$1';
It gives me the error message

Quote:The URI you submitted has disallowed characters.

When it's commented,all the pages except for the short url page works. So do you have any ideas how I can fix this?


URI Troubles - El Forum - 04-06-2009

[eluser]Mike Ryan[/eluser]
Hi,

Change the single quotes to double quotes:
Code:
$route['(:any)'] = "urls/getpage/$1";

If you use single quotes the variables are not interpolated, so you are requesting a page called $1, instead of the value of the $1 variable.


URI Troubles - El Forum - 04-06-2009

[eluser]stuffradio[/eluser]
No dice, it still gives me the annoying error.


URI Troubles - El Forum - 04-07-2009

[eluser]stuffradio[/eluser]
So can anyone give me pointers on htaccess files that would work for all servers and how to setup my routes to work the way I want them to?