CodeIgniter Forums

Full Version: .htaccess 301 Redirect + RedirectMatch + get strings + will someone think of the children?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]HdotNET[/eluser]
Hi there,

I am redeveloping an ancient Joomla website. Its done, all that is left to do is old url redirection. Fun fun fun.

There's a mixture of urls in the old site, some use GET query strings and some utilise .htaccess and Joomla-ness to serve content.

All the /slashed/urls/ without a get string work fine in the redirect.

Any url with a GET string leads to the CI message "The URI you submitted has disallowed characters.".... suggesting the redirect is not working with query strings. Putting die(print_r($_SERVER)) at the head of the index.php confirms this.

What is the correct way to redirect from a get query string to a /normal/url/ using mod_rewrite.

Anyone? Bueller?

H

Code:
#
# http://domain.com > http://www.domain.com conversion
#
Options +FollowSymlinks
RewriteEngine on



#
# straight url redirections from the old site
#
Redirect    301    /component/option,com_remository/Itemid,26/        http://www.domain.com/archive/
Redirect    301    /component/option,com_remository/Itemid,26/        http://www.domain.com/archive/
Redirect    301    /component/option,com_contact/Itemid,37/        http://www.domain.com/contact_us/
Redirect    301    /content/view/11/30/    http://www.domain.com/guidelines_for_authors/
Redirect    301    /content/view/10/29/    http://www.domain.com/why_publish/
Redirect    301    /index.php?option=com_remository&Itemid=26&func=search&parent=category&filecatid=0    http://www.domain.com/search/
Redirect    301    /component/option,com_reginterest/Itemid,32/    http://www.domain.com/registration_form/
Redirect    301    /content/view/20/40/    http://www.domain.com/links/


#
# dynamic url redirections from the old site
#
#downloads
RedirectMatch     301     /downloads(.*) /assets/file/beep/downloads$1
#tags
RedirectMatch     301     /index.php?option=com_remository&func=tag&tag_id=13&Itemid=43    http://www.domain.com/archive/subject/$1/
#folders
RedirectMatch     301     /index.php?option=com_remository&Itemid;=(.*)&func=selectfolder&filecatid;=(.*)    /archive/issue/$2/



## code igniter from now on.
# rewrite code from here
# http://ellislab.com/codeigniter/user-guide/general/urls.html
RewriteCond $1 !^(index\.php|favicon\.ico|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

El Forum

[eluser]Phil Sturgeon[/eluser]
You simply need to set CI to accept query strings. Cant remember exactly how thats done but I expect a short search will give you some answers.

Another way is to add ? & = into the following line.

Code:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
// should be
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-\?&=';

Mod rewrite would be a nightmare way of doing it, as you'd have to make sure all your get parameters and uri segments in the controller methods are all matched up exactly in the same order.

El Forum

[eluser]HdotNET[/eluser]
Don't want/can't use query strings within CI.

... all the GET params are in the same order.

H

--- side note. this thread appears in Google after 2 hours since initial post:

http://www.google.com/search?q=com_reginterest