Forums | Mahara Community
Support
/
Mod rewrite
02 November 2010, 14:25
Hello,
What mod-rewrite code do I insert in .htaccess if I want urls to be search engine friendly and show the user's display name?
For example, instead of showing
http://maharasite.com/user/view.php?id=11
How do I show http://maharasite.com/user/miamischools
Thanks, your suggestions are appreciated!
03 November 2010, 2:38
- I've created profile PHP file (without .php extension)
- placed it into root htdocs folder
- added some lines of code to .htaccess file
E.g.: http://mahara.site.org/profile/bob redirects to http://mahara.site.org/user/view.php?id=3 (if bob's id equals 3 in the database)
If the user doesn't exists than the script redirects back to the root folder. I don't know what the script should do (where to redirect) if user's profile isn't available to general public?
profile file (php file without .php extension)
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Gregor Anzelj
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2010 Gregor Anzelj, [email protected]
*
*/
define('INTERNAL', 1);
define('PUBLIC', 1);
require('init.php');
$data = explode('/', $_SERVER['PATH_INFO']);
$userid = get_field('usr', 'id', 'username', $data[1]);
if ($userid) {
redirect(get_config('wwwroot') . 'user/view.php?id=' . $userid);
} else {
redirect('/');
}
?>
php_flag register_globals off
php_flag magic_quotes_runtime off
php_flag magic_quotes_sybase off
php_flag magic_quotes_gpc off
php_flag log_errors on
php_flag allow_call_time_pass_reference off
php_value upload_max_filesize 50M
php_value post_max_size 50M
<Files config.php>
Order deny,allow
deny from all
</Files>
<Files .htaccess>
Order deny,allow
deny from all
</Files>
<Files lib.php>
Order deny,allow
deny from all
</Files>
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
FileETag None
<Files profile>
ForceType application/x-httpd-php
</Files>
24 November 2010, 12:06
Hi Gregor, thanks for this suggestion. I've tried it several times (the profile page without php extension in the htdocs root, and the .htaccess code in the domain top level and at the htdocs root level) but I can't seem to get it work. I am on version 1.3.0rc1... maybe that is the problem...??
25 November 2010, 1:23
I've placed both files (profile php script without .php extension and .htdocs) in the Mahara root folder and it worked for me...
HTH, Gregor
25 November 2010, 3:28
Hi Gregor,
I also want to change this.
I follow all above steps for implementing the Url.
This is not work for me.
Can you give a idea for that?
14 December 2010, 0:33
Hello Gregor,
I Hope you are Fine.
Can this functionality is useful for our View making Searchable on Google?
Please Reply for the Same.
14 December 2010, 5:26
I really don't know. I haven't tested it, but I think no.
Regards, Gregor
01 March 2011, 11:51
Thanks for this. Just put this in our Mahara site. Used 'go' instead of 'profile' but worked great
26 January 2011, 8:42
I've been trying to get yout code to work with version 1.3.3, but the only thing I get is the following message.I'checked data root diretory and it's writable, the users and permissions are also correct. Any advice?
Mahara: Site unavailable
Your defined data root directory, XXXXXXXXXXXXXXXXXXXXXX, is not writable. This means that neither session data, user files nor anything else that needs to be uploaded can be saved on your server. Please make the directory if it does not exist, or give ownership of the directory to the web server user if it does.
03 March 2011, 6:57
Sorry for late replay... been busy last two months.
I'll look into it in a couple of days...
Regards,
Gregor