The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.



Post new topic Reply to topic  [ 90 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Mon Aug 01, 2011 2:25 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
Quote:
Question 3 - Do you really mean redirect or do you mean rewrite?


I just realize that I was confusing those 2 terms, Imagine the poor newbie trying to grasp the concept....


No, I don’t want the folder name to appear.


So the far what I use in my setups are —>

I htaccess in the root + the normal Joomla htacces (in the subfolder)
I use this because I wasn’t sure to merge the 2, but now you tell me to do so (and probably keep only the one in the root)

My actual root ( I wasn’t able to do a permanent redirect sofar)
Code:
# Use PHP5CGI as default
AddHandler fcgid-script .php
# mysitename.ca
# .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.)?mysitename.ca$ [NC]

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/mysubfoldername/

# 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 ^(.*)$ /mysubfoldername/$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.)?mysitename.ca$ [NC]
RewriteRule ^(/)?$ mysubfoldername/index.php [L]



1— My configuration.php

Code:
as var $live_site = 'http://www.mysite.com' "


2— My htaccess file in Joomla is the original with :
# RewriteBase / —> (Still not active and commented)
I know it should be uncommented with the subfolder name to keep it out of the URL

but this setup do take out the subfolder name but leave me with 2 htaccess and a temporary redirect.

As you saying what I shoud have is one htacces and (I guess) should have a Permanent redirect.... 301


Other Stuff.................

This is my Glossary so far to be part of the final doc I will post here on the subject of Redirect, Rewrite and SEO - SEF

If you have time you can comment on those definition.... :)

Glossary:

—————————————————————————————————————
Understanding Redirect ???
This is my definition
Web server have as default setting to look for a file like index.html or index.php to display when an url is search by your browser.
e.g. If you type —> http://www.joomlacode.org the network search by default (whitout any rules in an htacces file) for a file index.html or index.php (in order of research html first, php after) to display a site or a unique file. In the case of http://www.joomlacode.org or www.joomlacode.org you will see that whatever you type you will see the final adress to be http://joomlacode.org/ This happen because you have a basic rule in the htaccess that “Redirect” http://www.joomlacode.org or www.joomlacode.org and http://joomlacode.org or even only joomlacode.org to the the same unique starter file and URL.

Proper redirects is the most important SEO and SEF Step and can even have a real impact on the overall speed of your site.
—————————————————————————————————————

—————————————————————————————————————
Difference between Rewriting and Redirecting?
Redirecting and rewriting are distinct, although many people use the terms interchangeably. It's better to understand the differences clearly, so you know how to do what you want with your server.
The main difference between Rewrite and Redirect can be described succintly:
• Rewrite is a Server-Side operation
• Redirect sends an immediate response to the Client

Rewriting is a Server-side operation
"The request is rewritten" means that on the server side, the result of the rewrite is served. The result could be a static page, or an image file, or a dynamic page (like a php page or an aspx page). Regardless of the result of the URL rewrite, the browser is not notified that a rewrite has occurred, inside the web server.
Using a rewrite, the browser can ask for http://myserver.com/definition/soccer.htm and receive the contents of c:\definition\football.htm, but will remain unaware that the server has done this substitution. The URL in the browser still reflects what the browser originally requested: /definition/soccer.htm.
This is a cause for confusion among many people, so I will repeat it: the browser cannot detect if the server has rewritten its request. There is no difference to the browser. If a server URL rewrite occurs, the browser is not informed. No update of the address in the browser URL address bar occurs, in the event of a rewrite.

Redirect sends an immediate response to the Client
A redirect implies sending an HTTP response to the client, with a new URL. Using a rewrite, the browser can ask for http://myserver.com/definition/soccer.htm and the server responds, effectively "No, you don't want football.htm, what you really want is soccer.htm". The server sends back an HTTP reply, with a response code of 301 (Moved Permanently) or 302 (Moved Temporarily), with a new URL http://myserver.com/definition/football.htm. Normally, when receiving the browser will update the browser address bar, and then make a new request for that new URL.
You can use Redirect and Rewrite together
In many cases, a set of rules will include both RewriteRule directives and RedirectRule directives. For example, often rules will redirect erroneous or malformed requests to a "Not Found" page, while correctly formed requests might get rewritten on the server side.
—————————————————————————————————————


—————————————————————————————————————
Permanent and Temporary redirect

Permanent 301
To summarize in a few lines, permanent 301 redirects are just as they sound. They are permanent redirects from an old URL to a new one (or a new domain/site alltogether). These redirects tell the search engines that the old location is to be removed from their index and replaced with the new location. Using 301 redirects is the most search engine friendly way to redirect traffic and engines, and far out weighs that of various JavaScript and Meta refresh redirects.

Temporary 302

Temporary 302 redirects are also as they sound; temporary. They are best use when moving an site to a new domain. Temporary redirects are telling the search engines to read and use the content on the new page, but to keep checking the original URL first as it will ultimately be reestablished.
—————————————————————————————————————

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Mon Aug 01, 2011 8:37 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
That's a good effort except this is badly explained and/or incorrect:
Quote:
You can use Redirect and Rewrite together
In many cases, a set of rules will include both RewriteRule directives and RedirectRule directives. For example, often rules will redirect erroneous or malformed requests to a "Not Found" page, while correctly formed requests might get rewritten on the server side.

There's no such thing as RedirectRule.

You can make an external redirect using RewriteRule or Redirect or RedirectMatch. Never use Redirect or RedirectMatch in the same site where RewriteRule is already in use.

You can also use RewriteRule to make an internal rewrite instead of an external redirect.

There is only a minor syntax difference or two between the two outcomes.

RewriteRule with domain name in the target or the [R] flag (or both) will generate a 302 redirect.

You must add the [R=301,L] flags to form a 301 redirect. A redirect should also include the domain name in the target.

RewriteRule with no domain name in the target, just an internal server path, results in an internal rewrite.

You should always add the [L] flag to EVERY RewriteRule directive unless you know EXACTLY why it should be omitted (almost never).

It is important to note that an external redirect is a URL to URL translation and that an internal rewrite is a URL to internal filepath translation.

Finally, you should never "redirect" to an error page. The error page should be returned at the originally requested URL.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Mon Aug 01, 2011 11:22 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
THANKS

I will review my definitions with your input and reformulate.

I don’t want to be to technical in the definition to keep the newbie alive for the more technical that will follow the glossary...

I really need this!!! :-[
Can you show me the exact htaccess files that will be proper redirects and rewrite for a normal hosting situation with Joomla.

Following is, I think, what 99% of Joomla user will be confronted with.....
Note: These htaccess are in the root with the other Joomla files.
• one 1.5.23 htaccess + www and no www + 301 redirect — no subdirectory
• one 1.5.23 htaccess + www and no www + 302 redirect — no subdirectory

Note : in this case the Joomla htaccess is remove and the created htaccess is place in the root (public_html or www)
• one 1.5.23 htaccess + www and no www + 301 redirect — with subdirectory (hide folder
• one 1.5.23 htaccess + www and no www + 302 redirect — with subdirectory

I fill really crappy to ask that, but I cannot count the hours that I pass to research exactly what I’m asking here.... to have vague uncomplete answers.

Simple basics complete good htaccess examples that represent what most Joomla users need should always be available on joomla.org

Without a proper htaccess a Joomla site is always a bad site, right from the start.

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Fri Aug 05, 2011 12:41 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
No, I dont want the subfolder to appear in the url...

Sorry with my babbling!

I just try every possibilities with a subfolder and always got the 500 errors. :'(

Thinking about it???
I think I NEED 2 htaccess when joomla is in a subfolder because I probably need the redirection/rewrite to the subfolder to take place at the root level and complete the 301 redirect after ( I guess??— I still don’t know and I’m to the point to call it quit and use my working temporary redirect

Root htaccess
Quote:
# Use PHP5CGI as default
AddHandler fcgid-script .php
# AddHandler application/x-httpd-php5s .php

# Bluehost.com
# .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.)?my-site-name.com$ [NC]

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/my-subfolder-name/

# 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 ^(.*)$ /my-subfolder-name/$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.)?my-site-name.com$ [NC]
RewriteRule ^(/)?$ my-subfolder-name/index.php [L]


<Files 403.shtml>
order allow,deny
allow from all
</Files>



My Joomla htaccess (the only change is)
Quote:

RewriteBase / my-subfolder-name

and my configuration.php with :
Quote:
var $live_site = 'http://www.mysiteurl.com';


Global configuration
Search Engine Friendly URLs —> Yes
Use Apache mod_rewrite —> Yes


I end up again with the same crappy temporary redirect....
This is few YEARS now that I search for a clear answer....... Discouraging.....
I don’t understand that something as crucial and basic is not clearly offer to the Joomla communauty. This is a shame on the complete platform...

But everything is working good with my url
Where ever I go in the site my subfolder name don’t show up...
http://www.mysitename.com/....

Still looking for a solution...

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Thu Aug 18, 2011 3:58 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
SADLY, It seem impossible to have a clear answer to this.

1— How to do a 301 permanent redirect (the normal thing with the www & no www) with Joomla in a subfolder

2— How to do a 301 permanent redirect (the normal thing with the www & no www) with Joomla in the normal root-www-public_html folder.

I’m so discourage about that. Nobody seem to have a clear written tutorial on redirect and rewrite for Joomla.

This is relly bad as it is fundemental to seo....

I will start another thread to have a final answer....
This discussion seem to be forgotten???

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Thu Aug 18, 2011 4:45 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Tue Sep 21, 2010 2:39 pm
Posts: 152
Chacapamac wrote:
SADLY, It seem impossible to have a clear answer to this.

1— How to do a 301 permanent redirect (the normal thing with the www & no www) with Joomla in a subfolder

2— How to do a 301 permanent redirect (the normal thing with the www & no www) with Joomla in the normal root-www-public_html folder.

I’m so discourage about that. Nobody seem to have a clear written tutorial on redirect and rewrite for Joomla.

This is relly bad as it is fundemental to seo....

I will start another thread to have a final answer....
This discussion seem to be forgotten???

Not by me at least...will be changing hosts soon and I am considering not installing joomla right in the public_html folder, but in a subfolder...I just have nothing constructive to say...

Spent a good deal of time last year trying to find practical solutions and guides to various such things and issues within the wide range of the Joomla platform, but being a total noob, with no background whatsoever, it was hopeless unless I took the task seriously and methodically and made it my priority to learn things the proper way...I didn't have the time for that so I made peace with the idea of having a lot of gaps in my knowledge of Joomla.

If a step by step guide with definitions and examples exists that makes a good documentation, I will try and do it myself, otherwise I am content with having a good-willing user help me out, even if I still don't get what works and what doesn't work and why...

For those still in the battlefield, good luck and courage, and I'll be watching your efforts on matters of interest


Top
 Profile  
 
PostPosted: Wed Aug 31, 2011 6:26 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
How to integrate a subfolder in there?
Code:
########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.example.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
########## End - 301 Redirect


Becoming desesperate with this?
Note: I have 2 htacces one in the root and the normal Joomla one in a subfolder root (public_html) —> Subfolder (with joomla installation (and default htacces) — I need www or no www to reach the site.

:(

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Fri Sep 02, 2011 12:16 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Tue Sep 21, 2010 2:39 pm
Posts: 152
Maybe you could very politely contact/pm an active member of the htaccess dev team to help you out?


Top
 Profile  
 
PostPosted: Fri Sep 02, 2011 2:14 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
Joomla have a htaccess dev team?
Thanks for your interest Pierre, apreciate... :D

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Fri Sep 02, 2011 6:38 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Tue Sep 21, 2010 2:39 pm
Posts: 152
Yeah, I meant those involved in the suggested Master Htaccess file...

I feel your pain...


Top
 Profile  
 
PostPosted: Sun Sep 04, 2011 10:14 am 
User avatar
I've been banned!

Joined: Tue Oct 26, 2010 3:54 am
Posts: 1295
hi all,

I am using joomla 1.7 and work fine to my localhost. This is my first time transfer to remote host.
after transfer all the db and folder to remote host. i rename the htaccess.txt to .htaccess. do i need to change anything in .htaccess if the remote host did not allow for http://www.xxxx.subdomain.com only they allow for http://xxxxx.subdomain.com.

if there should be changes on .htaccess can anybody guide me where to change? and what code to be change?

Thanks


Top
 Profile  
 
PostPosted: Mon Oct 17, 2011 10:16 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Wed Sep 10, 2008 6:05 pm
Posts: 288
Location: Essex, England, United Kingdom
http://docs.joomla.org/Htaccess_examples_%28security%29

Hi all I'm not really aware of this subject, so someone else will have to validate the correctness of the page above, but I thought it might help some people.

_________________
Just another lonely website designer trying to make his way.
https://www.squareballoon.co.uk


Top
 Profile  
 
PostPosted: Tue Oct 18, 2011 11:29 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
Thanks for the link uaintgotthisid

I’m still looking for a good 301 redirect when joomla is in a subfolder.

Still looking...
???

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Tue Oct 18, 2011 12:28 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Wed Sep 10, 2008 6:05 pm
Posts: 288
Location: Essex, England, United Kingdom
Shouldn't you be able to use the link that I sent? I swear it had a 301 redirect in there, and it shouldn't matter if it's in a sub folder I don't think, so long as the .htaccess file is in the root of that folder too.

I think that's right anyhow...

_________________
Just another lonely website designer trying to make his way.
https://www.squareballoon.co.uk


Top
 Profile  
 
PostPosted: Tue Oct 18, 2011 2:47 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
Well I’m trying for a long time now to acheive a 301 redirect in a subfolder and it don’t seem to be as simple as it look.

1— You need to have an htaccess in the root to redirect to the subfolder

2— You need the htaccess inside Joomla

3— Both have to play nice together

4— You have to take out the subfolder from the url (easy)

5— All that should give a nice, efficient 301 with good URL

Try for years now — No success

Always endup to use a temporary redirect and no redirect in the Joomla htaccess

I will give my Kingdom for that horse.
(I don’t have to much....)

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Wed Oct 19, 2011 12:37 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Wed Sep 10, 2008 6:05 pm
Posts: 288
Location: Essex, England, United Kingdom
lol horses are amazing animals, so big! It's amazing that there used to be other large mammals but most died out. Anyway.. I digress.

I'm no expert on redirection, so I'm not the guy to ask, but if you only want to redirect within the subfolder I'm not sure I understand why you need a htaccess in the root. Like I said I'm no expert, have you tried asking other members? Find a huge contributor and then try asking them politely if they might be able to provide you with a direction towards some resources?

_________________
Just another lonely website designer trying to make his way.
https://www.squareballoon.co.uk


Top
 Profile  
 
PostPosted: Wed Oct 19, 2011 6:56 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
You got the root where most of joomla install take place. If you put all joomla files and put them in a folder —> Root —> Subfolder —> Joomla files. You need to indicate visitors to that domain url yourdomain.com to go look inside that subfolder to find the index.php file that make the site. Whitout the external htaccess the yourdomain.com will go nowhere and look for an index.html or php to show the site in the root, not in the subfolder.

I ’m talking to a real expert right now Nicholas K. Dionysopoulos (Dev of Akkeba backup and admin tools) and I should have an answer finally that I will bring here for other to use.

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Tue Feb 07, 2012 5:17 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Jan 22, 2012 8:50 pm
Posts: 1
Well, not sure if this has been answered, but this will work::

http://www.drichproductions.com/random- ... ectory.php

However, what I have found is that the login/logout button ONLY works on the homepage after using the above code.

I am open to any suggestions on how to get full functionality of the form on ALL pages...thanks.


Top
 Profile  
 
PostPosted: Tue Feb 07, 2012 2:35 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
Sadly the previous code don’t seem to work... (from cruise2001)

My htaccess (obviously with “YourSiteName” and “YourSubfolderName” replace...

The file is situated in the root of the web folder same level of the Subfolder containing Joomla

Code:
Options +FollowSymLinks

RewriteEngine On
RewriteBase /



# This section must .comme first!

# Add trailing slash if path does not contain a period or end with a slash

RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) http://www.YourSiteName.com/$1/ [R=301,L]



#Change http://YourSiteName..com to http://www.YourSiteName.com (Optional)
RewriteCond %{HTTP_HOST} ^YourSiteName.com$
RewriteRule ^/?(.*)$ http://www.YourSiteName..com/$1 [R=301,L]



#Rewrites http://www.YourSiteName.com/YourSubfoderName to http://www.YourSiteName.com/

RewriteCond %{REQUEST_URI} !^/YourSubfoderName

RewriteRule ^(.*)$ YourSubfoderName/$1 [L]


Configuration file —>
Code:
 var $live_site = 'http://www.YourSiteName.com';


My .htaccess in the joomla subfolder (only the important code shown (This is a complete normal joomla htacces for 1.5.25)

Code:
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch

#  mod_rewrite in use

RewriteEngine On

# RewriteBase /



All that return a nice 500 error


After years of looking around for a solution I abandonned the idea to have a clean 301 redirect in a subfolder and decide to place joomla directly in the root...

I hate loosing...

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Tue Feb 07, 2012 3:42 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
You probably have some sort of infinite internal rewrite loop.

There's probably a small typo somewhere in the code or a couple of rules that conflict.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Tue Feb 07, 2012 4:19 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
INCREDIBLE BUT TRUE — I FIND IT — NICE 301 REDIRECT IN A SUBFOLDER WHITOUT THE SUBFOLDER NAME


AFTER MANY YEARS — :(


HOW TO:

—>Root htaccess —> Replace “YourSiteName” and “YourSubfolderName”

—> The file is situated in the root of the web folder same level of the Subfolder containing Joomla

Code:
# Activate the rewrite engine.
RewriteEngine on

# Forward YourSiteName.com to www.YourSiteName.com
RewriteCond %{HTTP_HOST} !^www\.YourSiteName\.com$
RewriteRule ^(.*)$ http://www.YourSiteName.com/$1 [L,R=301]

# Forward www.YourSiteName.com to YourSiteName.com
# RewriteCond %{HTTP_HOST} ^www\.YourSiteName\.com$
# RewriteRule ^(.*)$ http://YourSiteName.com/$1 [L,R=301]

# Change YourSiteName.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?YourSiteName.com$ [NC]

# Change 'YourSubfolderName' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/YourSubfolderName/

# Don't change these lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change 'YourSubfolderName' to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /YourSubfolderName/$1 [L]

# Change YourSiteName.com to be your main domain again.
# Change 'YourSubfolderName' 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.)?YourSiteName.com$ [NC]
RewriteRule ^(/)?$ YourSubfolderName/index.php [L]


Configuration file —>
Code:
var $live_site = 'http://www.YourSiteName.com';


—> My .htaccess in the joomla subfolder (only the important code shown (This is a complete normal joomla htacces for 1.5.25)
Code:
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch

#  mod_rewrite in use

RewriteEngine On

# RewriteBase /



JUST NEED A GURU TO OPTIMIZE FOR DOUBLE CONTENT AND ALL —> PLEASE

I’m so happy I can cry........ :D

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Tue Feb 07, 2012 8:11 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
Your final rule will never run because all requests will have been handled by the rule before because its pattern is (.*) which matches all requests even if empty (i.e. root).

Change the rule order.

If your site is actually working at this point, it's because the DirectoryIndex directive is instead handling the request.

This line is not needed on your final rule:
RewriteCond %{HTTP_HOST} ^(www.)?YourSiteName.com$ [NC]

Remember to escape all literal periods in RegEx patterns. There are a number where this has not been done.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Sun Feb 12, 2012 1:51 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
So sorry to ask but I have still difficulty to grasp all that :(

I will need you help —> g1smd to clean that up

You tell me to do 3 thing...

1-
Quote:
Your final rule will never run because all requests will have been handled by the rule before because its pattern is (.*) which matches all requests even if empty (i.e. root).

Change the rule order.


—> Do you talk about the last rule
Code:
RewriteRule ^(/)?$ YourSubfolderName/index.php [L]
— Where should I put it?

2-
Quote:
If your site is actually working at this point, it's because the DirectoryIndex directive is instead handling the request.

This line is not needed on your final rule:
RewriteCond %{HTTP_HOST} ^(www.)?YourSiteName.com$ [NC]

—> I just take out that condition ?

3-
Quote:
Remember to escape all literal periods in RegEx patterns. There are a number where this has not been done


do you mean ?
RewriteRule ^(.*)$ http://www.YourSiteName.com/$1 [L,R=301]
to
ewriteRule ^(\.*)$ http://www.YourSiteName.com/$1 [L,R=301]

RewriteRule ^(.*)$ /YourSubfolderName/$1 [L]
to
RewriteRule ^(\.*)$ /YourSubfolderName/$1 [L]

I’m really guessing here------ ;)

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Sun Feb 12, 2012 6:14 am 
I've been banned!

Joined: Sat Sep 17, 2011 4:05 pm
Posts: 21
hi
excuse me can i use diffrent htaccess for one of my folders

_________________
http://[spam].ir
http://www.[spam].ir


Top
 Profile  
 
PostPosted: Mon Feb 13, 2012 3:25 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
Quote:
excuse me can i use diffrent htaccess for one of my folders

Yes you can use different htacces for different folder..

As example; if you create a password to protect a particular folder in a website by using one of those “Protect Folder” button in a web hosting Control Panel (c-panel) it will install a htaccess file in that particular folder with the user/password needed to acces that particular folder on the web...

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Tue Mar 06, 2012 12:43 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
:-[

Sorry to be back with this...

I follow the direction from g1smd — Anyway, what I can understand....

Quote:
Your final rule will never run because all requests will have been handled by the rule before because its pattern is (.*) which matches all requests even if empty (i.e. root).

Change the rule order.

If your site is actually working at this point, it's because the DirectoryIndex directive is instead handling the request.

This line is not needed on your final rule:
RewriteCond %{HTTP_HOST} ^(www.)?YourSiteName.com$ [NC]

Remember to escape all literal periods in RegEx patterns. There are a number where this has not been done.



This is what I came up with :

• I take out the rule:
Quote:
This line is not needed on your final rule:
RewriteCond %{HTTP_HOST} ^(www.)?YourSiteName.com$ [NC]

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.

# Activate the rewrite engine.
RewriteEngine on

# Forward YourSiteName.com to www.YourSiteName.com
RewriteCond %{HTTP_HOST} !^www\.YourSiteName\.com$
RewriteRule ^(.*)$ http://www.YourSiteName.com/$1 [L,R=301]

# Forward www.YourSiteName.com to YourSiteName.com
# RewriteCond %{HTTP_HOST} ^www\.YourSiteName\.com$
# RewriteRule ^(.*)$ http://YourSiteName.com/$1 [L,R=301]

# Change 'YourSubfolderName' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/YourSubfolderName/

# Don't change these lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change 'YourSubfolderName' to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /YourSubfolderName/$1 [L]

# Change YourSiteName.com to be your main domain again.
# Change 'YourSubfolderName' 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.)?YourSiteName.com$ [NC]
RewriteRule ^(/)?$ YourSubfolderName/index.php [L]


Now I have to understand what “Change the rule order.” and “Remember to escape all literal periods in RegEx patterns. There are a number where this has not been done”

and make the change...

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Wed Mar 07, 2012 1:18 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
In RegEx patterns " \. " means a literal period and " . " means ANY character.

As a pattern ^www.example.com$ would match wwwZexampleZcom but since you want to match a literal period, the RegEx pattern should be "www\.example\.com".

Escaping is not required in the rule target. Ever.


The final 5 lines of your code will never run. The line 6th from the end has (.*) as the RegEx pattern. This means "match ALL requests". So the line 6th from the end handles EVERY request hitting the server, and no code after that ever gets to deal with any request. So, if you need the last 5 lines of code to do something, anything, then change the rule order so that the last 5 lines of code are not the last 5 lines in the file, and are located somewhere else.


The "-f" and "-d" checks are very very inefficient. On a busy site this will literally beat your server hard [drive] to death. You're asking the server to check twice to see if a file exists for every request even when there's no chance the request is ever going to be rewritten and is always going to be served by a file. That's dreadfully inefficent. Add a RewriteCond before those checks which preselects which URL request patterns might possibly be rewritten and only check those to see if a file exists. You could list extensions that will always be rewritten (and do away with the "-f" and "-d" checks") or list extensions that will not ever be rewitten and precede the pattern with NOT (using a ! here) i.e. use a pattern which excludes requests for images, stylesheets, and javascript files.

The pattern ^(/)?$ matches requests for http://www.example.com/ and http://www.example.com// with two slashes. Why do you need that pattern? And why capture the second slash in a backreference that isn't then re-used?


The overall design of the file should be to list all of the redirects first and all of the rewrites last. Within each of those two groups list the most specific rules first (i.e. those which deal with the least number of rules) and the most general rules last (this is often the one with (.*) as the pattern).


Use example.com in code examples. See RFC 2606.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Wed Mar 07, 2012 2:14 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
Code:
# 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.

# Replace example.com and /subfolder/ with the real names.

# Redirect to canonical hostname and rewrite to internal subfolder.

# Activate the rewrite engine
RewriteEngine on

# 1. Redirect non-canonical hostame requests to www.example.com
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

# 2. Rewrite root request to index file in subfolder
RewriteRule ^$ /subfolder/index.php [L]
RewriteRule !. /subfolder/index.php [L]
# (pick one of the above two lines, they are equivalent)

# 3. Rewrite requests to subfolder
# If the request has not already been rewritten to /subfolder/
RewriteCond %{REQUEST_URI} !^/subfolder/
# and is not a request that is always handled by a file
RewriteCond %{REQUEST_URI} !\.(png|gif|jpe?g|css|js|zip|txt)$
# and does not actually exist as a file or folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# rewrite the request to be handled by the folder
RewriteRule (.*) /subfolder/$1 [L]


If the site uses non-www URLs then ruleset 1 needs to be changed to this:

Code:
# 1b. Redirect non-canonical hostame requests to example.com
# RewriteCond %{HTTP_HOST} !^(example\.com)?$
# RewriteRule (.*) http://example.com/$1 [R=301,L]


Of course, if the site uses extensionless URLs, ruleset 3 simplifies to this:

Code:
# 3b. Rewrite requests to subfolder
# If the request has not already been rewritten to /subfolder/
RewriteCond %{REQUEST_URI} !^/subfolder/
# then rewrite the extensionless request to the subfolder
RewriteRule ^(([^/]+/)*[^/.]+)$ /subfolder/$1 [L]


You'll also need a ruleset ahead of all the other rules to redirect requests for named index files. The rule target will be a new URL without the index file name, merely ending with a trailing flash.


On many Joomla sites the above code will cause problems, espcially on those using HTTPS for some requests and those using forms of any sort - hence the additional lines of code in the more complex file that I have posted a few months ago.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Wed Mar 07, 2012 2:04 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Feb 20, 2008 6:50 am
Posts: 643
Location: Canada, Montreal
I just try this:
Code:
# Use PHP5CGI as default (Needed For Bluehost CGI)
AddHandler fcgid-script .php

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

# Replace example.com and /subfolder/ with the real names.

# Redirect to canonical hostname and rewrite to internal subfolder.

# Activate the rewrite engine
RewriteEngine on

# 1. Redirect non-canonical hostame requests to www.example.com
RewriteCond %{HTTP_HOST} !^(www\.mysitename\.com)?$
RewriteRule (.*) http://www.mysitename.com/$1 [R=301,L]

# 2. Rewrite root request to index file in subfolder
RewriteRule ^$ /mysubfolder/index.php [L]
#RewriteRule !. /mysubfolder/index.php [L]
# (pick one of the above two lines, they are equivalent)

# 3. Rewrite requests to subfolder
# If the request has not already been rewritten to /subfolder/
RewriteCond %{REQUEST_URI} !^/mysubfolder/
# and is not a request that is always handled by a file
RewriteCond %{REQUEST_URI} !\.(png|gif|jpe?g|css|js|zip|txt)$
# and does not actually exist as a file or folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# rewrite the request to be handled by the folder
RewriteRule (.*) /mysubfolder/$1 [L]


The site is 301 but appear unformatted even after emptying all cache ?


If I follow you well here —

For extensionless URL you simply not recommend the subfolder approach?

_________________
Can God help us?
Marketing, SEO, Web development - Powered by Joomla!
http://www.grafcomm.ca/


Top
 Profile  
 
PostPosted: Wed Mar 07, 2012 9:05 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
You can use a subfolder for extensionless URLs.

Your problem sounds like the links to your CSS and JS files are pointing to the wrong location. Use 'view source' to see the code. Be aware that it is the browser that evaluates the URL to be requested for these other resources.


The part of the code that excludes requests for real files from being rewritten might be the culprit. Where are those "real files" located? If those files are also in the subfolder then those requests SHOULD also be rewritten.
Requests for Joomla pages should be rewritten to the index file in the subfolder and requests for real files should be rewritten to their location inside the subfolder. That's two separate rules doing very similar things.

_________________
Online since 1995.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 90 posts ]  Go to page Previous  1, 2, 3  Next



Who is online

Users browsing this forum: No registered users and 38 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group