skifr Posted March 26, 2012 Share Posted March 26, 2012 Hi all, I'm new in here I was looking for similar threads but haven't found something helpful yet I've tried to 301 redirect the following url http://www.bmeteor.co.il/index.php?act=ecommerce&cat=5175&id=ERR&sort=price to the homepage http://www.bmeteor.co.il/ any help would be really aprreciated thank you in advance Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/ Share on other sites More sharing options...
requinix Posted March 26, 2012 Share Posted March 26, 2012 And what did you try? Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/#findComment-1331340 Share on other sites More sharing options...
skifr Posted March 27, 2012 Author Share Posted March 27, 2012 And what did you try? I've tried this: RewriteCond %{QUERY_STRING} ^act=ecommerce&cat=5175&id=ERR&sort=price$ RewriteRule ^/index\.php$ http://www.bmeteor.co.il/ [L,R=301] Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/#findComment-1331624 Share on other sites More sharing options...
requinix Posted March 27, 2012 Share Posted March 27, 2012 Drop the leading / from the RewriteRule. Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/#findComment-1331629 Share on other sites More sharing options...
skifr Posted March 27, 2012 Author Share Posted March 27, 2012 Drop the leading / from the RewriteRule. nope, that doesn't work I also tried this one: RewriteCond %{QUERY_STRING} ^act=ecommerce&cat=5175&id=ERR&sort=price$ RewriteRule ^index.php$ http://www.bmeteor.co.il/ [L,R=301] but it redirects to the same address only without index.php Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/#findComment-1331634 Share on other sites More sharing options...
requinix Posted March 27, 2012 Share Posted March 27, 2012 Unless you put a query string in the substitution URL, mod_rewrite will keep the original. Apache 2.4 has a flag to disable that but it's so new I doubt you have it. RewriteRule ^index.php$ http://www.bmeteor.co.il/? [L,R=301] That does stick a ? in the URL. The alternative is doing the redirection in index.php itself (like right at the top). if ($_SERVER["QUERY_STRING"] == "act=ecommerce&cat=5175&id=ERR&sort=price") { header("Location: http://www.bmeteor.co.il/"); exit; } By the way, you know the full name isn't necessary if it's your site? Including the [R] flag is enough to make it redirect. RewriteRule ^index.php$ /? [L,R=301] header("Location: /"); Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/#findComment-1331646 Share on other sites More sharing options...
skifr Posted March 27, 2012 Author Share Posted March 27, 2012 Unless you put a query string in the substitution URL, mod_rewrite will keep the original. Apache 2.4 has a flag to disable that but it's so new I doubt you have it. RewriteRule ^index.php$ http://www.bmeteor.co.il/? [L,R=301] That does stick a ? in the URL. The alternative is doing the redirection in index.php itself (like right at the top). <?php if ($_SERVER["QUERY_STRING"] == "act=ecommerce&cat=5175&id=ERR&sort=price") { header("Location: http://www.bmeteor.co.il/"); exit; } By the way, you know the full name isn't necessary if it's your site? Including the [R] flag is enough to make it redirect. RewriteRule ^index.php$ /? [L,R=301] header("Location: /"); sorry, but again-there's a problem this one actually works: RewriteRule ^index.php$ http://www.bmeteor.co.il/? [L,R=301] The problem is that it redirects every page on the site (no matter what page) to the homepage I only want this page (or other pages with parameters) to have the redirection I also tried to use the redirection on the index.php file -and it doesn't work PS-if it's possible, I prefer to have the redirect through the HTACESS file thanks Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/#findComment-1331693 Share on other sites More sharing options...
requinix Posted March 28, 2012 Share Posted March 28, 2012 Did you remove the RewriteCond? Because it has to be there. Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/#findComment-1332056 Share on other sites More sharing options...
skifr Posted March 29, 2012 Author Share Posted March 29, 2012 Did you remove the RewriteCond? Because it has to be there. If you're asking about the index.php-I'm not sure exactly where to implement the code haven't worked out with the HTACESS as well this is the index.php, maybe you can tell me where exactly to implement this thanks <?php /** * @version $Id: index.php 14401 2010-01-26 14:10:00Z louis $ * @package Joomla * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. * @license GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. */ // Set flag that this is a parent file define( '_JEXEC', 1 ); define('JPATH_BASE', dirname(__FILE__) ); define( 'DS', DIRECTORY_SEPARATOR ); require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null; /** * CREATE THE APPLICATION * * NOTE : */ $mainframe =& JFactory::getApplication('site'); /** * INITIALISE THE APPLICATION * * NOTE : */ // set the language $mainframe->initialise(); JPluginHelper::importPlugin('system'); // trigger the onAfterInitialise events JDEBUG ? $_PROFILER->mark('afterInitialise') : null; $mainframe->triggerEvent('onAfterInitialise'); /** * ROUTE THE APPLICATION * * NOTE : */ $mainframe->route(); // authorization $Itemid = JRequest::getInt( 'Itemid'); $mainframe->authorize($Itemid); // trigger the onAfterRoute events JDEBUG ? $_PROFILER->mark('afterRoute') : null; $mainframe->triggerEvent('onAfterRoute'); /** * DISPATCH THE APPLICATION * * NOTE : */ $option = JRequest::getCmd('option'); $mainframe->dispatch($option); // trigger the onAfterDispatch events JDEBUG ? $_PROFILER->mark('afterDispatch') : null; $mainframe->triggerEvent('onAfterDispatch'); /** * RENDER THE APPLICATION * * NOTE : */ $mainframe->render(); // trigger the onAfterRender events JDEBUG ? $_PROFILER->mark('afterRender') : null; $mainframe->triggerEvent('onAfterRender'); /** * RETURN THE RESPONSE */ echo JResponse::toString($mainframe->getCfg('gzip')); Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/#findComment-1332472 Share on other sites More sharing options...
requinix Posted March 30, 2012 Share Posted March 30, 2012 What's your .htaccess right now? Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/#findComment-1332631 Share on other sites More sharing options...
skifr Posted March 31, 2012 Author Share Posted March 31, 2012 What's your .htaccess right now? RewriteEngine On RewriteCond %{HTTP_HOST} ^bmeteor\.co\.il [NC] RewriteRule ^(.*)$ http://www.bmeteor.co.il/$1 [R=301,NC,L] Options +FollowSymLinks DirectoryIndex index.php RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.bmeteor.co.il/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] thanks Quote Link to comment https://forums.phpfreaks.com/topic/259761-htacess-redirects-with-get-parametrs/#findComment-1332972 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.