Incredible that the Joomla communauty don’t have a complete set of instructions for the different type of server/joomla configuration on permanent and temporary redirect.
This is crucial and basic to obtain the perfect SEF SEO...
Thanks to the participants of this discussion to bring some light...
I need a little more guidance...
NOTE: my Joomla files are in a
subfolder of public_html.
I guess that the configuration of 2 .htaccess files is necessary when the Joomla files are in a subfolder
—> one in the root
(to point to the subfolder) and the normal one
(include in all Joomla installation)QUESTION 1:Do we need those 2 .htaccess and how they should be use together?
—>This question will answer herself by the following....
TEMPORARY REDIRECT—302QUESTION 2:This is the default of my server and even the normal Joomla include is a temporary (302) redirect, How come we don’t go with a 301 right away?
This is my actual working (temporary) redirect1 The root .htaccess — Path —> public_html/.htaccess —
(Complete code)Code:
# .htaccess main domain to subfolder redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.ca$ [NC]
# Change 'subfolder' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subfolder/
# Don't change these lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subfolder' to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /subfolder/$1 [L]
# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.ca$ [NC]
RewriteRule ^(/)?$ subfolder/index.php [L]
2— My Joomla .htacces file Path—> subfolder/.htaccess file (partial important code)
Code:
## Can be commented out if causes errors, see notes above.
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
#
# mod_rewrite in use
RewriteEngine On
ANDCode:
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
# RewriteBase /subfolder
Note: remark that my RewriteBase command is commented out and my url DO NOT have the subfolder include
3— My Joomla configuration.php file Path—> subfolder/configuration.php file
Code:
var $live_site = 'http://www.example.ca';
PERMANENT REDIRECT — 301This is my actual TRIAL of permanent redirect htaccess.
1 The root .htaccess — Path —> public_html/.htaccess —
(Complete code)Code:
# Do not change this line.
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
# Add trailing slash if path does not contain a period or end with a slash
RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) http://www.example.ca/$1/ [R=301,L,NC]
# Change http://yoursite.com to http://www.yoursite.com
RewriteCond %{HTTP_HOST} ^example.ca$
RewriteRule ^/?(.*)$ http://www.example.ca/$1 [R=301,L,NC]
# Exclude any other directories in the site root that should NOT be affected.
# include the Joomla subdirectory
# best not to use directories in your site root that also exist in joomla e.g. images
RewriteCond %{REQUEST_URI} !^/subfolder/
#or separate multiple directories with |
#RewriteCond %{REQUEST_URI} !^/(dir1|dir2|dir3)
#if you have other domain (add-on examples) they should be added here to not affect
#RewriteCond %{HTTP_HOST} !^otherdomains.ca$
#Rewrites http://www.domain.ca/ to http://www.domain.ca/subdir
RewriteRule ^(.*)$ /subfolder/$1 [L]
NOTE:
a) I need to exclude other directories in the site root that should NOT be affected.
b) I have subdomains
Same configuration.php and Joomla subfolder .htaccesQUESTION 3:This is a mixmatch of what I find on the web and it’s probably wrong. I think this regroup most of the normally encounter configurations and question about the redirect subject.
If some Joomla Guru can clarified this for me it will answered a extremly important
(BASIC) point to have a solid base for the deployment of succesfull Joomla site...
I need direction on this one ?
Thanks in advance.
