MDN

Go Back   Mambo - Forums Closed for posting > Mambo 4.5.5 - Stable > General Questions

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old November 9th, 2003, 21:54   #1
Saka
 
Saka's Avatar
 
Join Date: Oct 2003
Location: Sweden
Posts: 760
Saka is on a distinguished road
Default

In Mambo 4.5 we decided to implement Search Engine Friendly URLs.

SEF in Mambo is for Apache only. It is using mod_rewrite for pointing server to the right file whilst all logic is in PHP. There are only 3 lines in .htaccess for mod_rewrite directions.

To turn SEF support ON:
1) You must run Apache
2) You must have mod_rewrite enabled
3) Your server must allow .htaccess override
4) Set $mosConfig_sef= "1" in configuration.php
5) Rename htaccess.txt to .htaccess

You will notice that sections/content/items have nice URLs like:
http://www.site.com/content/view/5/2/
and components have URLs like:
http://www.site.com/component/option...tact/Itemid,3/

Troubleshooting
If you expirience problems with SEF please make sure you tripple checked these troubleshooting steps:
1) You must run Apache
To check this go to Mambo administration > System > System Info. Server type should be listed next to Web Server. SEF will not run on IIS, so don't bother trying.
2) You must have mod_rewrite enabled
To check this go to Mambo administration > System > System Info. Click on PHP Information tab. Scroll down until you find Loaded Modules row. mod_rewrite should be listed here. If it's not ask your web host to activate mod_rewrite.
3) Your server must allow .htaccess override
To check this delete everything from your .htaccess file and write a simple command here, for example:
Code:
Redirect /google.html http://www.google.com
Now point your browser to http://www.yoursite.com/google.html If it redirects you to google.com then you are OK.
4) Set $mosConfig_sef= "1" in configuration.php
You can also activate SEF under Site > Global Configuration.
5) Rename htaccess.txt to .htaccess
This can be done with a FTP program. Note the dot in the beginning! Also note that you can't do this on windows, you must rename it directly on server.

Information for component developers: What you have to do in order to SEF enable your CMTs (Components/Modules/Templates):
You must convert all links in CMTs to SEF links. This is done with a function called sefRelToAbs().
Example:
Before you had link or form pointing to:
index.php?option=com_contact&Itemid=$Itemid
Now you just do this:
echo sefRelToAbs("index.php?option=com_contact&Itemid=$ Itemid");
This will transform this relative URL to link like:
http://www.domain.com/component/opti...tact/Itemid,3/
Now mod_rewrite will point Apache to index.php and sef.php will do the back-transforming magic.
This function will just return the same link if SEF are disabled so it's safe to code your CMTs with it from now on.

Note that SEF is turned OFF by default and no changes in any way are needed if you are running Mambo the old way, without SEF.

Please make sure that you have right settings before posting that it doesn't work. I will be deleting all comments from people that haven't checked above 5 steps. So: check your php-info and make sure you run Apache and mod_rewrite module is loaded. Make sure you renamed htaccess.txt to .htaccess and that you turned SEF on in configuration.php.

If you want to further enhance your site having SEF URLs like:
http://www.site.com/section/category/item/ take a look on SEF advance here:
http://forum.mamboserver.com/showthread.php?t=246
__________________
Emir Sakic
http://www.sakic.net

Last edited by Saka : May 3rd, 2005 at 21:42.
Saka is offline  
Old November 9th, 2003, 22:56   #2
MindXing
 
MindXing's Avatar
 
Join Date: Oct 2003
Location: Phoenix, AZ, USA
Posts: 304
MindXing is on a distinguished road
Default

Two questions.

Quote:
Originally Posted by Saka
For you wondering what you have to do in order to SEF enable your CMT's:

1) You must use absolute URL's instead of relative. So if you called template/image.gif it will not work with SEF because server will try to pull content/view/1/2/template/image.gif.
What's does CMT mean?

Will it work to use <base href=http://www.mydomain.com/> to set the absolute path for my elements?

_M_
__________________
This is your life. Are you who you want to be? This is your life. Is it everything you dreamed it would be? -- Switchfoot
MindXing is offline  
Old November 9th, 2003, 23:45   #3
Saka
 
Saka's Avatar
 
Join Date: Oct 2003
Location: Sweden
Posts: 760
Saka is on a distinguished road
Default

CMT means Components/Modules/Templates.
Yes, using base href we can eliminate need for making every relative URL absolute. Thanks for the tip, already done.
However you will still need to use sefRelToAbs() in CMT's to convert old fashion links to SEF ones (if you want your component to act search engine friendly).
__________________
Emir Sakic
http://www.sakic.net
Saka is offline  
Old November 10th, 2003, 07:42   #4
Anders
 
Anders's Avatar
 
Join Date: Oct 2003
Location: Doetinchem Netherland
Posts: 18
Anders is on a distinguished road
Default

This is great news Thank you!

Are there any facts one loos of server preformance?
Anders is offline  
Old November 10th, 2003, 07:55   #5
Lil Devil
 
Posts: n/a
Default

this will have performance impact, using mod_rewrite this is well know. Do a 'Google' and you will find many discussions on this.
 
Old November 10th, 2003, 07:56   #6
Jason407
 
Jason407's Avatar
 
Join Date: Oct 2003
Location: Orlando, Florida USA
Posts: 968
Jason407 is on a distinguished road
Default

HEHE, I was wondering when you guys where going to let this info go public. Of course, now you will have even more pressure to release beta3!!!!

question...if a component or 3rd party addon does not use the code to give SEF links, will the addon still work on a site with SEF enabled?

My thinking based upon how the mod_rewrite works is that it should. It just wouldn't have SEF urls.
__________________
Jason M. Murphy made Mambo stuff, available here:Jason Murphy Dot Net
Recently, he has been Directing low-budget Zombie Movies!, check out Jason M. Murphy on IMDB.
Jason407 is offline  
Old November 10th, 2003, 07:58   #7
Lil Devil
 
Posts: n/a
Default

goto www.phil-taylor.com as he is running SEF at the moment and you will see ReMOSitory (which is not currently SEF'd) still works and produces standard urls.
 
Old November 10th, 2003, 08:00   #8
Jason407
 
Jason407's Avatar
 
Join Date: Oct 2003
Location: Orlando, Florida USA
Posts: 968
Jason407 is on a distinguished road
Default

Great!
Looks awesome! Can't wait to play with it myself!

Again...wonderful work boys!
__________________
Jason M. Murphy made Mambo stuff, available here:Jason Murphy Dot Net
Recently, he has been Directing low-budget Zombie Movies!, check out Jason M. Murphy on IMDB.
Jason407 is offline  
Old November 10th, 2003, 08:10   #9
Lil Devil
 
Posts: n/a
Default

Pssst ... take a peek at http://sf.net/projects/mambo ...

;-)
 
Old November 10th, 2003, 08:13   #10
Jason407
 
Jason407's Avatar
 
Join Date: Oct 2003
Location: Orlando, Florida USA
Posts: 968
Jason407 is on a distinguished road
Default

HEHE!!!!! NICE!!!!!!!!!!!!!!!
__________________
Jason M. Murphy made Mambo stuff, available here:Jason Murphy Dot Net
Recently, he has been Directing low-budget Zombie Movies!, check out Jason M. Murphy on IMDB.
Jason407 is offline  
Old November 10th, 2003, 08:21   #11
Saka
 
Saka's Avatar
 
Join Date: Oct 2003
Location: Sweden
Posts: 760
Saka is on a distinguished road
Default

Quote:
Originally Posted by Lil Devil
this will have performance impact, using mod_rewrite this is well know. Do a 'Google' and you will find many discussions on this.
Even though it is mod_rewrite based it only contains 2 simple .htaccess lines.
All rewriting logic is in PHP so I think it should have less impact on performance and manipulation will be easier.
__________________
Emir Sakic
http://www.sakic.net
Saka is offline  
Old November 10th, 2003, 08:24   #12
Saka
 
Saka's Avatar
 
Join Date: Oct 2003
Location: Sweden
Posts: 760
Saka is on a distinguished road
Default

Quote:
Originally Posted by Jason407
question...if a component or 3rd party addon does not use the code to give SEF links, will the addon still work on a site with SEF enabled?
It will but component itself will produce old-fashion URL's.

If you want component itself to produse SEF URL's then you need to use sefRelToAbs() function as explained above.
__________________
Emir Sakic
http://www.sakic.net
Saka is offline  
Old November 11th, 2003, 06:39   #13
Roberto
 
Join Date: Nov 2003
Posts: 1
Roberto is on a distinguished road
Default

Hello Friends,

I get a "Direct Access to this location is not allowed." if i try the SEF feature, but only on content pages. So i tried to find the diffence and i found out that if i create in my mosroot a "content" and therein a "section" Directory everything works fine !?

greets Roberto

My MOS is installed i a Dir mambo45_b3 below the wwwroot.

PHP built On: Windows NT OEMCOMPUTER 5.1 build 2600
Database Version: 4.0.14-max-debug
PHP Version: 4.3.3RC2-dev
Web Server: Apache/2.0.47 (Win32) PHP/4.3.3RC2-dev
WebServer to PHP interface: apache2handler
Mambo Open Source Version: 4.5 Beta-1.0.3 [Christine] 09/11/2003 22:42 GMT
User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461; Arcor 2.0)
Relevent PHP Settings: Safe Mode: OFF
Open basedir: none
Display Errors: ON
File Uploads: ON
Magic Quotes: ON
Register Globals: ON
Output Buffering: OFF
Session save path: .;D:\minixampp\tmp
Session auto start: 0
XML enabled: Yes
Zlib enabled: Yes
Disabled Functions: none
WYSIWYG Editor: htmlarea2
Roberto is offline  
Old November 11th, 2003, 08:03   #14
Saka
 
Saka's Avatar
 
Join Date: Oct 2003
Location: Sweden
Posts: 760
Saka is on a distinguished road
Default

Hi Roberto,

Thanks, this has been solved. Just replace this line in your .htaccess:
RewriteRule ^content/(.*) index.php
with this line:
RewriteRule ^content(.*) index.php

Then you should be able to delete content directory.
__________________
Emir Sakic
http://www.sakic.net
Saka is offline  
Old November 11th, 2003, 17:28   #15
dmb
 
Posts: n/a
Default

Saka

This is the topic that was locked last night - Sticky: Search Engine Friendly URL's [SEF] in 1.0.3 - was locked! If it had been open I would have posted my observation and fix here.

So you can delete the other post

--------------------------------------

When I tried SEF I got 404 errors

I had to add

RewriteBase /

to the .htaccess (between RewriteEngine on and the rules, note I did not change the rules)

Apache docs state

Notice: If your webserver's URLs are not directly related to physical file paths, you have to use RewriteBase in every .htaccess files where you want to use RewriteRule directives.

see http://httpd.apache.org/docs/mod/mod...ml#RewriteBase

Background

The host I use (oneandone.co.uk) allows multiple domains on one account by using subdirectories of the main server. This means that the URL does not match the server directory.

Server root = /
domain.org = /domain1/
anotherdomain.com = /anyname/
_________________
dmb
 
Old November 11th, 2003, 22:23   #16
Saka
 
Saka's Avatar
 
Join Date: Oct 2003
Location: Sweden
Posts: 760
Saka is on a distinguished road
Default

I haven't noticed that this topic was locked. If that's the case it must have been locked by error, sorry.

And, as I said before, this issue has been fixed in CVS.
__________________
Emir Sakic
http://www.sakic.net
Saka is offline  
Old November 11th, 2003, 23:12   #17
lewisteo
 
lewisteo's Avatar
 
Join Date: Oct 2003
Location: Some Where
Posts: 329
lewisteo is on a distinguished road
Default

Can I have a little private "How Tos" as

1. I really don't understand.
2. It does not work on my site.
3. What exactly do I need to preset the server in order that it works.
lewisteo is offline  
Old November 11th, 2003, 23:13   #18
dmb
 
Posts: n/a
Default

Saka,

I usually try to post in the right place - no problem - however

The change in CVS to

[code:1:d03cbfd951]#
# mod_rewrite in use
#

RewriteEngine On

#
# Rules
#

RewriteRule ^content(.*) index.php
RewriteRule ^component/(.*) index.php

[/code:1:d03cbfd951]

Makes no difference to the production of 404 errors on my host - adding RewriteBase / does work - either with this CVS version or the previous one in release 1.0.3 - this may be host dependent. I suggest you add comment re RewriteBase to htaccess.txt file to save others searching for the solution.
 
Old November 11th, 2003, 23:16   #19
Saka
 
Saka's Avatar
 
Join Date: Oct 2003
Location: Sweden
Posts: 760
Saka is on a distinguished road
Default

Well I can't just put
RewriteBase /
What if somebody don't have Mambo in root directory?

If you have Mambo in
http://www.domain.com/mambo/
then your .htaccess would point to
http://www.domain.com/index.php

In that case you would need to have:
RewriteBase /mambo

So this would be site dependent so it's better to let user add it himself (if he needs it which is rare). Usually you have same directory as web path.

However I will add the commented line as you suggested.
__________________
Emir Sakic
http://www.sakic.net
Saka is offline  
Old November 11th, 2003, 23:18   #20
Saka
 
Saka's Avatar
 
Join Date: Oct 2003
Location: Sweden
Posts: 760
Saka is on a distinguished road
Default

Quote:
Originally Posted by lewisteo
Can I have a little private "How Tos" as

1. I really don't understand.
2. It does not work on my site.
3. What exactly do I need to preset the server in order that it works.
Every single thing you are asking are carefuly explained in the first post.
So please read it and then ask specific which part you don't understand.
__________________
Emir Sakic
http://www.sakic.net
Saka is offline  
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SEF advance Saka Commercial Products and Services available for Mambo 714 November 29th, 2006 13:12
improved search engine postme Wishlist & Feature Requests 6 July 13th, 2005 10:00
newsfeed category addon & search engine URLs tomtom General Questions 0 September 20th, 2004 04:02
Search in Mambo Dragon Wishlist & Feature Requests 14 February 22nd, 2004 07:06
Total Search Engine Optimisation For Mambo Pages Scottish Charlie Wishlist & Feature Requests 2 December 20th, 2003 05:02


All times are GMT -7. The time now is 07:21.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.