Short URLs & Rewrite Rules

In order to enable short URL's with phpFox2 you will need mod_rewrite, most servers today have support for this. To enable this feature open the file on your server:

htaccess.txt

Look for:

RewriteBase /

If you have installed phpFox2 in a sub-folder you will need to change the trailing slash with the sub-folder path. For example if you installed your site on:

http://www.yoursite.com/folder/ 

You will need to change the RewriteBase to:

RewriteBase /folder/

If you installed your phpFox2 in your sites root directory (eg. http://www.yoursite.com ) you can leave this setting as it is.

Next lets rename the file

htaccess.txt

to

.htaccess

Once you have done that open the file

/include/setting/server.sett.php

and look for

$_CONF['core.url_rewrite'] = '2';

and replace that with

$_CONF['core.url_rewrite'] = '1';

By setting this to "1" this will transform your sites URLs from:

http://www.yoursite.com/index.php?do=/blog/title/ 

to

http://www.yoursite.com/blog/title/ 

Save and close the file. You should now have short url's enabled on your site.

Sub-Domain Short URLs (Beta)

We are currently testing rewriting URLs with wildcard sub-domains. In order to use this feature your server must support wildcard sub-domains. With this setup each of your users will have their own sub-domain. For example if we had a users profile using the short URL method like:

http://www.yoursite.com/username/ 

with this setup it would be:

http://username.yoursite.com/ 

Earlier we used a link to display how a blog would look with short URLs like:

http://www.yoursite.com/blog/title/ 

with this setup it would be:

http://blog.yoursite.com/title/ 

In order to set this up (assuming you have already followed the instructions above to install short URLs) open the file:

include/setting/server.sett.php

look for:

$_CONF['core.url_rewrite'] = '1';

replace with:

$_CONF['core.url_rewrite'] = '3';

Next, open the file:

.htaccess

Look for:

RewriteBase /

Under that add:

RewriteCond %{HTTP_HOST} ^admincp.example.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php?do=/$1

Notice where we have:

example.com

Change that to your host name. Note this is not the full path to where your site is installed, this is just your host name.

In some environments you may need to add the sections as subdomains, if this does not work out of the box please consult with your hosting company.


Comments
Only verified clients can post comments on our community. If you have any questions feel free to contact us here.
Terry wrote at July 20, 2011, 5:21 pm
0 Votes

If you are getting a 404 error you might have accidentally put in "folder" in the .htaccess file and not the actual folder name.

Terry
Nick wrote at June 29, 2011, 4:47 pm
0 Votes

Have the same issue as everyone else. Added RewriteBase / to the .htaccess file and changed 2 to 1. Menu links went to correct url (http://site.com/blog) but every page returned a 404 error. Has anyone solved this issue?

Last Update on June 29, 2011, 4:47 pm by Nick
Nick
gt568 wrote at May 30, 2011, 8:54 pm
0 Votes

I did follow the example above for the first step to try and eliminate the "/index.php?do=/user/" portion of the URL but I too had broken links. It worked fine when changing the number from 2 to 1 I could see the URL's were correct but they were also broken. I have the site installed on my root directory so I only renamed the htaccess file (eliminating the .txt). I could not get it to work so I changed it back so the site would work. Any ideas?

gt568
AgentXE wrote at May 17, 2011, 10:31 pm
0 Votes

NiceSmile
Thanks

AgentXE
intergral wrote at May 2, 2011, 8:07 pm
0 Votes

how is this done in 2.1?

$_CONF['core.url_rewrite'] doesnt have numbers?

intergral
Compumatrix wrote at April 17, 2011, 5:18 pm
0 Votes

NumarkJanjan... You really don't need to follow the instruction word for word. The mistake is when you cut and paste this line:

RewriteBase /folder/

if you're not using a folder, keep it as is.

RewriteBase /

This will cause problems if you did change it.

Compumatrix
Made In Asia wrote at April 13, 2011, 12:28 pm
0 Votes

i follow the instruction but all the menu link is not working all the link is going to homepage Smile

Made In Asia
21FunSalute wrote at January 28, 2011, 8:38 am
0 Votes

I followed the Short URLs & Rewrite Rules for phpfox2 word for word and now I got the following warning message in the AdminCP...

"Main configuration file (include/setting/server.sett.php) is writable. This is a security risk and this file should not have any "write" permission".

When I now try to modify the include/setting/server.sett.php file so it has no "write" permissions, it is not saving the "read" only permissions and keeps automatically switching back to include "write" permissions.

Anyone know what I can do to correct this asap?

Last Update on January 28, 2011, 8:50 am by Ray kennedy
21FunSalute
multynet wrote at January 27, 2011, 1:55 pm
0 Votes

How to rewrite the accent éèàûçü ect.... ?

Thanks

multynet
ChristieLuv wrote at January 19, 2011, 1:26 am
0 Votes

Hi, I've got the same thing. Ive got a 404 not found error, when my server has the Wildcard installed.

ChristieLuv
Displaying 21 to 30 of 35