|
|
#1 |
![]() Join Date: Oct 2003
Location: Sweden
Posts: 760
![]() |
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 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 Last edited by Saka : May 3rd, 2005 at 21:42. |
|
|
|
|
#2 | |
![]() Join Date: Oct 2003
Location: Phoenix, AZ, USA
Posts: 304
![]() |
Two questions.
Quote:
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 |
|
|
|
|
|
#3 |
![]() Join Date: Oct 2003
Location: Sweden
Posts: 760
![]() |
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). |
|
|
|
|
#4 |
![]() Join Date: Oct 2003
Location: Doetinchem Netherland
Posts: 18
![]() |
This is great news
Are there any facts one loos of server preformance? |
|
|
|
|
#5 |
|
Posts: n/a
|
this will have performance impact, using mod_rewrite this is well know. Do a 'Google' and you will find many discussions on this.
|
|
|
#6 |
![]() Join Date: Oct 2003
Location: Orlando, Florida USA
Posts: 968
![]() |
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. |
|
|
|
|
#7 |
|
Posts: n/a
|
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.
|
|
|
#8 |
![]() Join Date: Oct 2003
Location: Orlando, Florida USA
Posts: 968
![]() |
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. |
|
|
|
|
#9 |
|
Posts: n/a
|
|
|
|
#10 |
![]() Join Date: Oct 2003
Location: Orlando, Florida USA
Posts: 968
![]() |
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. |
|
|
|
|
#11 | |
![]() Join Date: Oct 2003
Location: Sweden
Posts: 760
![]() |
Quote:
All rewriting logic is in PHP so I think it should have less impact on performance and manipulation will be easier. |
|
|
|
|
|
#12 | |
![]() Join Date: Oct 2003
Location: Sweden
Posts: 760
![]() |
Quote:
If you want component itself to produse SEF URL's then you need to use sefRelToAbs() function as explained above. |
|
|
|
|
|
#13 |
![]() Join Date: Nov 2003
Posts: 1
![]() |
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 |
|
|
|
|
#14 |
![]() Join Date: Oct 2003
Location: Sweden
Posts: 760
![]() |
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. |
|
|
|
|
#15 |
|
Posts: n/a
|
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 |
|
|
#16 |
![]() Join Date: Oct 2003
Location: Sweden
Posts: 760
![]() |
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. |
|
|
|
|
#17 |
![]() Join Date: Oct 2003
Location: Some Where
Posts: 329
![]() |
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. |
|
|
|
|
#18 |
|
Posts: n/a
|
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. |
|
|
#19 |
![]() Join Date: Oct 2003
Location: Sweden
Posts: 760
![]() |
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. |
|
|
|
|
#20 | |
![]() Join Date: Oct 2003
Location: Sweden
Posts: 760
![]() |
Quote:
So please read it and then ask specific which part you don't understand. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |