I apologize if these issues have been covered somewhere else...I am fairly new at working with the .htaccess file and have spent days researching and troubleshooting possible solutions but nothing seems to work...and I can't seem to find the exact scenario that applies to me. It also is a long post but I tried to be thorough and include code so as to not waste anyone's time by giving you insufficient info.
I have redesigned a website and to minimize any search engine problems I need to configure my .htaccess file to redirect my old page urls to my new page urls. However, there are several other issues to consider which has me confused:
* Root level contains the new html website which links to new Joomla content;
* new Joomla is installed in the subdirectory /menus;
* new Joomla has SEF urls and mod_rewrite enabled;
* old Joomla which is installed in the subdirectory /cms used long dynamic urls (query strings);
* there are some canonical issues going on and the old Joomla page urls which need to be redirected or rewritten are non-www while the new Joomla site's page urls are www;
* I don't want the old site to remain visible so my plan was to either delete the /cms folder or block it from Google by password protecting it.
I have been successful with my .htaccess file rewriting my urls to sef urls in my new joomla install located in my /menus directory. This .htaccess file is located in the /menus folder and the code is below.
I also tested the code to rewrite the non-www versions of the website to www and I also was successful. I placed this file in the root directory. I removed it for now until I get the url redirect working which is most important.
PROBLEM > I have tried all types of code in the .htaccess file and have placed it at the root and/or in the /menus and /cms directories and I haven't been able to redirect the old content page urls to the new content page urls. It doesn't work...nothing happens.
The code I was using for this was:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^option=com_content&task=view&id=21&Itemid=34$
RewriteRule ^/index.php$ [
domain.com...] [R=301,L]
I tried this in the .htaccess file in the /cms directory first and then tried putting this code in the .htaccess file at the root level (but added /cms in front of the /index)...it didn't work either way. Would it matter if the old page url doesn't have the www and the new page url does?
The code which is currently included in the .htaccess file in the new joomla directory /menus is below:
##
# @packageJoomla
# @copyrightCopyright (C) 2005 - 2012 Open Source Matters. All rights reserved.
# @licenseGNU General Public License version 2 or later; see LICENSE.txt
##
##
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations. It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file. If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's. If they work,
# it has been set by your server administrator and you do not need it set here.
##
## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks
## Mod_rewrite in use.
RewriteEngine On
## Begin - Rewrite rules to block out some common exploits.
# If you experience problems on your site block out the operations listed below
# This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.
## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects
##
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##
# RewriteBase /
## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.
Thanks for any help provided...I have exhausted myself and am just about to give up. I have 3 locations to choose from...the root, /cms and /menus...that I could put the htaccess file in and I am having trouble figuring if everything can go into one file or if it needs to be split up so there are no conflicts and if so what code goes where and what order or protocol is used.