I would like to know how to add a trailing slash to joomla categories, but have no extension on articles.
Example, i want- xxx.com/category1/ and xxx.com/category1/article
Currently google sees- xxx.com/category1/ and xxx.com/category1 as duplicate content.
I would say you probably want to keep the URL without the trailing slash rather than the other way around. This just keeps it cleaner in the event that you have a category page which later needs a query string on the end of it. For example /categroy1?page=2 reads better than /categroy1/?page=2. This is personal preference though, Google does not really care so long as it's consistent.
The easy way to achieve what you are trying to do is through the .htaccess file in the root of your website.
Seems to be a few threads online about this subject. I've just tried a few of the solutions myself and the one that seems to work best is listed here https://forum.joomla.org/viewtopic.php?t=701030.
In summary you need to add the following to your .htaccess file just below the 'RewriteEngine On' statement.
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !administrator
RewriteCond %{REQUEST_URI} !component
RewriteRule ^(.*)/$ $1 [R=301,L]
Note that the Rewrite Base is needed, but if you are running your site in a sub folder (as you might in dev) you need to include that folder in the RewriteBase.
Apparently the !administrator and !component statements are needed to prevent some infinite loops when viewing the admin area, or a component content page without a SEF URL. There may be other exclusions that are needed.
Other options to solve your problem include canonical tags on the pages to tell the search engines which one you want indexed. Extensions to perform the redirect for you. Or if you have a really small site, use Joomla!'s redirect component to redirect every page you don't want to the one you do.
Hope this helps.
KevBallard
Related
So, lately I've been dealing with an issue relating to mod_rewrite and it seems nobody is trying to do anything like it. Every question people have is about trying to exclude directories from the rewrite, when I want them to be included like any other.
For instance, assuming my root directory with .htaccess file in it is www.example.com/root/
When I type in made up directory, such as www.example.com/root/asdfasdf, I have my .htaccess file set to redirect me to www.example.com/root/index.php?url=asdfasdf without change what's in the address bar on my browser
However, in trying to do the same with a real directory, such as www.example.com/root/admin, it not only changes the url in the address bar but changes it to www.example.com/root/admin/?url=admin.
Can anyone explain to me what's going on. I've tried all kinds of different regular expressions and flags and the ones that redirect anything still cause this same issue. can I go to www.example.com/root/admin and still get redirected to the root folder while hiding that the query string is ?url=admin.
[UPDATE: additional information 11-30-2012]
Like I said, I've tried it will multiple different lines of code and come out with the exact same redirect issue, assuming the redirect doesn't just fail altogether and produce a 500 error. Here's one of my latest iterations, though, which has produced the issue of not ignoring direcotories.
RewriteEngine On
RewriteBase /root/
RewriteCond %{REQUEST_FILENAME} !^(.\*\\.("png"|"jpg"|"gif") [NC]
RewriteRule (.\*?) index.php?url=$1 [QSA]
The rewrite condition is to keep the engine from rewriting if a picture is being requested (for css and img tags). I only didn't mention it previously because I have tried removing that line and it has made no difference.
I'm not exactly a master of mod_rewrite, though, so if you see any errors with anything I've written, please feel free to let me know.
It's not entirely clear from your question what you are trying to do and it would have been helpful to see what your .htaccess file actually looked like. However the following lines in an .htaccess file in the root folder:
RewriteCond %{REQUEST_URI} !^/root/index\.php
RewriteRule (.*) /root/index.php?url=$1 [L]
Will silently redirect requests made to http://www.example.com/root/madeupfolder/madeupfile.php to http://www.example.com/root/index.php?url=madeupfolder/madeupfile.php and will also do the same for real folders. So if the folder admin exists under root, then requests to http://www.example.com/root/admin will be silently redirected to http://www.example.com/root/index.php?url=admin
If however you wanted to serve up folders and files that actually exist, but rewrite requests for folders and files that do not exist, then you would need to adjust the rewrite like so
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/root/index\.php
RewriteRule (.*) /root/index.php?url=$1 [R=301]
This would still rewrite requests made to http://www.example.com/root/madeupfolder/madeupfile.php to http://www.example.com/root/index.php?url=madeupfolder/madeupfile.php, but for real folders and files, such as requests made to http://www.example.com/root/admin, the admin folder would be served up.
Hope this helps, but if you can clarify your question a bit then I can try and help again.
I am taking over an old website, and need to change the domain name.
The current domain is http://www.example.com/folder/ and the new domain is http://example.school.nz
An example of an existing and desired URL is:
Before: http://www.example.com/folder/index.php?page=sport
Desired: http://example.school.nz/about-us/sport
The site is built using CMSMS (http://www.cmsmadesimple.org), so pages and URL's are generated through the CMS, although it's easy enough to export a list of URL's.
Ideally I could set up 301 redirects for the entire site so the user doesn't get 404'd. Any clues to the easiest way to accomplish this?
It depends on how general you want things to be, but this set of rules will do what you asked in your question:
RewriteCond %{HTTP_HOST} .*
RewriteCond %{QUERY_STRING} page=sport
RewriteRule ^folder/index.php http://example.school.nz/about-us/sport? [L,R=301]
OK...
I have setup things so that when the following page is requested (browser users and servers)
http://www.visualise.ca/?_escaped_fragment_=corona
the website returns the following the content of this (HTML snapshot)
http://www.visualise.ca/corona
Where 'corona' always change, it varies depending on the page the users or servers are requesting. It could also be
http://www.visualise.ca/?_escaped_fragment_=anne-au-cherry
redirecting to
http://www.visualise.ca/anne-au-cherry
Thanks
UPDATE: OK let me be more clear. I use AJAX to load my Wordpress post and they appear like this http://www.visualise.ca/#!/corona when loaded. But it's not crawlable by Google that request to serv them as http://www.visualise.ca/?_escaped_fragment_=corona so I modified Wordpress to do so. Now Google can crawl my page and index its content and accessing the HTML snapshot available at http://www.visualise.ca/corona.
The problem is that when I paste the http://www.visualise.ca/#!/corona link to facebook it seems to read the http://www.visualise.ca/?_escaped_fragment_=corona and is unable to read the content. But when I paste directly the http://www.visualise.ca/?_escaped_fragment_=corona link it works, it reads http://www.visualise.ca/corona (The HTML).
So I thought maybe if I could redirect http://www.visualise.ca/?_escaped_fragment_=corona to http://www.visualise.ca/corona it would solve my problem.
Here is the existing .htaccess file
#--- DH-PHP handlers ---
AddHandler fastcgi-script fcg fcgi fpl
AddHandler php-fastcgi .php
Action php-fastcgi /cgi-bin/dispatch.fcgi
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The common mistake that a lot of people do is trying to match whole URL including query string. The reality is: when matching URL, the pattern get applied to path part of it and query string has to be matched separately.
Use this rule: it will issue 301 Permanent Redirect from this kind of URL /?_escaped_fragment_=corona to /corona (where corona can be anything).
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=([^&]*)
RewriteRule .* http://%{HTTP_HOST}/%1? [R=301,L]
I guess your question is really "how do I do this kind of redirection?". So the answer is here:
There are three ways that I could think of, each with slight differences.
Doing the redirection server side
This basically means you set redirect headers in your response. In php, you could do this using the header function. It can also do a delayed redirect, in which case you need to worry about the contents of the page.
Doing it using client side using html's "http-equiv" meta tags. This way the page always gets loaded. Example here.
doing it via javascript. Thats you basic document.location.href thing. You need to figure out a way to pass the argument to javascript, or have your JS read it from the address url itself.
Since I've shown you 3 ways of doing this, I really hope that's what you're looking for :P
Update after seeing the comments:
The above methods will cause the URL to change. If you don't want the URL to change, but show the contents of that other page on your original page, you caould either do that using iframes (baaaad), or do the decent thing and set up URL rewriting.
:)
RewriteEngine on
RewriteRule \?_escaped_fragment_=(.*?) /$1 [L,R=301]
is it what are you looking for?
After researching, I have come to some conclusions for utilizing SEO URLs. For semi-static .php based sites that have file names such as index.php, about.php, contact.php etc I am using htaccess mod_rewrite rules so that for example 'www.mysite.com/about' can be used in place of 'www.mysite.com/about.php'. In such cases, all of my menus and links are then pointing at the SEO URL.
What I have found out though, is that even though nothing in my site references the .php extensions, if I enter them directly, they stick. So, I can get to the about page using /about or /about.php, and each will show as entered. It seems reading through posts here that this is a common issue.
My question is, does this matter? If nothing in my site references the .php extensions in a link or menu, do i need to be worried about duplicate content??
I was told I need to add something in htaccess like:
redirect 301 /about.php http://www.mysite.com/about
for each page to eliminate the possibility but I don't understand if this is really an issue in this case?
Two Questions:
Q1. "Does this matter"?
Answer: Not if you've never exposed the .php URLs before. If you have, then the answer changes to "yes".
Q2. What .htaccess?
Answer:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [R=301,L]
Your URLs are SEO friendly if there are some keywords in it that relate to the content and if they are not overly dynamic in a sense that Google Bot can interpret them (take a look at the Google Webmastertools and read this).
So I would not worry about "mysite.com/about" versus "mysite.com/about.php". I would rather watch out to avoid duplicate content if you want to change the URLs.
Here are some more links for further reference:
Making Website URLs SEO Friendly and Pretty
Some articles and advice on Duplicate Content
We had an old coldfusion website a couple of years ago and I recently realized there are some old links still floating around causing 404 errors. I don't know what was on any of the pages and I just want to redirect them to a new static page. Our new site is a Joomla 1.5 site with SEF URLs turned on.
An old URL would look like this: http://www.example.com/content.cfm?id=2010 where the only difference between the URLs would be the number after id=.
I want to redirect any URL that begins with content.cfm to a the static page http://www.example.com/oops-thats-an-old-page which lists some helpful links to find what they are looking for.
I am successfully accomplishing this with the following code in the .htaccess file:
RewriteCond %{QUERY_STRING} id=
RewriteRule (.*) http://www.example.com/$1? [R=301]
RewriteRule ^content\.cfm$ /oops-thats-an-old-page [R=301,L]
I'm new to rewriting URLs and I'm not sure this is the best way to do it. I am also concerned that it may brake non-sef joomla URLs that I am not aware of because they also have the id= in them.
Can I make the rewrite conditional on whether or not it begins with content.cfm?
The first rule will already be applied when the query contains id=. If you don’t want that but rather redirect only if /content.cfm with query containing id= was requested, try this rule:
RewriteCond %{QUERY_STRING} id=
RewriteRule ^content\.cfm$ /oops-thats-an-old-page? [R=301,L]