• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.htaccess 301 Redirect + RedirectMatch + get strings + will someone think of the children?

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?


# 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
RedirectMatch     301     /downloads(.*) /assets/file/beep/downloads$1
RedirectMatch     301     /index.php?option=com_remository&func=tag&tag_id=13&Itemid=43    http://www.domain.com/archive/subject/$1/
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]

[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.

$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.

Don't want/can't use query strings within CI.

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


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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.