User Login    
   Register now!

Howtodude.NET / How to rewrite URLs for SmartSection

howtodude 4/17 12:11
14
Howtodude.NET > Computers > Internet > CMS > XOOPS

Aim:

The users of your website prefer URLs like www.example.com/beach-resorts.html to URLs like www.example.com/modules/smartsection/item.php?itemid=1. Rewriting a URL in a way that it becomes descriptive will probably improve your ranking in search engines like Google, Yahoo or MSN. This howto describes how to rewrite URLs for SmartSection 2.13, a content management module for XOOPS, XOOPS Cube and ImpressCMS.

How to rewrite URLs for SmartSection:

Nearly out-of-the-box, SmartSection allows to rewrite a URL like www.example.com/modules/smartsection/item.php?itemid=41 to URL's like www.example.com/smartsection.item.41/orlando-florida.html or www.example.com/ss.item.62/orlando-florida.html . This greatly improves your search engine ranking for two reasons. In the first place, search engines are known to prefer static URLs. Secondly, you have a number of relevant search terms in your URL. For a blog or a news section, this way of URL rewriting is probably the best available for XOOPS. If you download and extract SmartSection from www.smartfactory.ca, you will find a file called seo.txt in the extra/seo folder. This contain the instructions of rewriting URL's this way. 

There are also a number of disadvantages of rewriting URLs this way. A URL like www.example.com/smartsection.item.41/orlando-florida.html contains some irrelevant keywords: "smartsection", "item" and "41". If somebody publishes your URL in the way I just did, you will have these irrelevant keywords linking to your site. Furthermore, if you are trying to rank high on competitive keywords like "florida" "hotel" and "deals", it is better to have a URL like www.example.com/florida-hotel-deals . Why? Because search engines analyse the hierarchy of your site, the closer a page is located to the root, the more important it is. Personally, I like to use hierarchy to give my site a logical structure like www.example.com/destinations/florida/best-hotel-deals . This makes your site easier to crawl for both humans and search engines and such a URL contains more relevant keywords. If you try to rank on combinations of keywords without making URLs that look to spammy, the later might be a better option.

So how to get a URL like www.example.com/beach-resorts.html or www.example.com/destinations/florida/best-hotel-deals in XOOPS? Well, there is a way of doing it, but before I explain it, I have a warning: This way of URL rewriting is very labor-intensive! I recommend it only for static content, not for weblogs or news sections. It is recommended that you use this way of URL rewriting with a clone of SmartSection (recommended reading: How to clone SmartSection manually; use the name of your clone whenever this articles mentions "smartsection"), so that you can continue to use SmartSection in the regular way.

First, make sure that there is a .htaccess file in the root of your site that contains the following line:

RewriteEngine On


For each URL like www.example.com/destinations/ , you have to add two lines to your .htaccess file like:

RewriteRule ^destinations$ /destinations/ [R=301]
RewriteRule ^destinations/$ modules/smartsection/seo.php?seoOp=item&seoArg=1 [QSA,L]

The "1" in the code above can be replaced by any article's number.

In case you have a multilingual site, you should do it like this:

RewriteRule ^destinations$ /destinations/ [R=301]
RewriteRule ^destinations/$ modules/smartsection/seo.php?seoOp=item&seoArg=1⟨=en [QSA,L]

In order to get www.example.com/destinations/florida/best-hotel-deals.html , add something like this for each URL to your .htaccess file:

RewriteRule ^destinations/florida/best-hotel-deals.html$ modules/smartsection/seo.php?seoOp=item&seoArg=2 [QSA,L]


Or something like this for multilingual sites:

RewriteRule ^destinations/florida/best-hotel-deals.html$ modules/smartsection/seo.php?seoOp=item&seoArg=2⟨=en [QSA,L]


After rewriting your URLs, you will notice that XOOPS and SmartSection's internal way to link to your websites pages still uses the old URLs. For this reason, I cleaned the standard templates of SmartSection on my sites so that all internal links were removed. After this, you have to add the links to these statical pages to your site's menu manually, otherwise these pages cannot be found by visitors and search engines. In order to avoid duplicate content (what search engines don't like), you may want to close your folder /modules/smartsection/ for search engines by ensuring that the root of your website contains a file Robots.txt that contains the following lines:

User-agent: *
Disallow: /modules/smartsection/

Final advice: Keep some structure in your .htaccess file, especially if you are rewriting this way as your .htaccess file may become very lenghty. Structure makes it much easier to manage.

 

 

 

 

 

Disclaimer: this howto reflects the personal opinion of the writer.
The comments are owned by the poster. We aren't responsible for their content.
Add YOUR own howtos today!

It's fun, it's free, increase your productivity! Archive your own howtos on Howtodude.NET so that you can access these from everywhere at every time!

Register now!