Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
SEO friendly URLs

 

 


1980
New User

Dec 26, 2011, 6:52 PM

Post #1 of 5 (1617 views)
Shortcut
SEO friendly URLs Can't Post

Hi,

aren't there any rewrite settings in CMS Builder?

at the moment my details pages look like

eg
/index.php?Test-5

would like to have /Test-5.php or /Test-5/

Thanks


Tom P
User


Dec 27, 2011, 12:24 PM

Post #2 of 5 (1595 views)
Shortcut
Re: [1980] SEO friendly URLs [In reply to] Can't Post

Hi 1980,

CMSB doesn't have a built in .htaccess editor so you'll have to create your own .htacces file and add the rewrite rules yourself.

To do so, create a plain text file and save it with the extension ".htaccess" (but no file name).

Edit that file and add the following (to change URL from "/Test-5" to "/index.php?Test-5" )


Code
Options +FollowSymlinks 
RewriteEngine on
RewriteRule ^/([a-z]+)-([0-9]+) http://yourdomain.com/index.php?$1-$2 [NC]


This will allow you to use links in your code of the form "http://yourdomain.com/Test-5" and have the browser show the page as if it were viewing "http://yourdomain.com/index.php?Test-5".

There are a lot of things that .htaccess can do - a good resource for htaccess rules is http://www.htaccess-guide.com/.

Hope this helps,

Tom


(This post was edited by Tom P on Dec 27, 2011, 12:24 PM)


1980
New User

Dec 29, 2011, 6:24 PM

Post #3 of 5 (1558 views)
Shortcut
Re: [Tom P] SEO friendly URLs [In reply to] Can't Post

thanks for the help Tom

the actual file is called parody.php in a directory called 'index', so I tried the variations on following code

RewriteRule ^/index/parody.php?([a-z]+)-([0-9]+) http://www.mysite.com/index/parody.php?$1-$2 [NC]

but that gives a 404 error (had a look on your link, but couldn't find more info on these rewrites)


(This post was edited by 1980 on Dec 29, 2011, 6:30 PM)


NigelGordijk
User

Dec 30, 2011, 9:48 AM

Post #4 of 5 (1541 views)
Shortcut
Re: [Tom P] SEO friendly URLs [In reply to] Can't Post

I'm looking for something similar, I think.

Is there a way for me to manually create an URL for a page or set up a "dummy" url that automatically forwards to a different page? I'm working on some public notifications and would like to have a web address on some printed documents. It would be nice to list a shorter address then what is automatically created by the CMS. For example, I would create a new page called www.wilmot.ca/trails which could be its own page or redirect to http://www.wilmot.ca/departments-development-details.php?Wilmot-Trails-4, whichever is easier.

Nigel Gordijk
 
Common Sense Design: User-focused Web design
Tel: 001 519 342 5348  |  Web: www.commonsensedesign.net


Tom P
User


Dec 30, 2011, 10:59 AM

Post #5 of 5 (1532 views)
Shortcut
Re: [NigelGordijk] SEO friendly URLs [In reply to] Can't Post

Hello all,

In my first response I missed an important character from the RewriteRule - the '$' at the end of the expression! In any case, here is a more detailed explanation of what to do...



1 - Check that mod_rewrite is loaded: create a php file with the following in it

Code
<?php phpinfo(); ?>

Upload it to your server and then look for 'mod_rewrite' (use f3 and type in 'mod_rewrite'). If it's not loaded, you'll need to get your server admin to enable it for you.

2 - At the start of your .htaccess file, make sure you have the following:

Code
Options +FollowSymlinks 
Options +Indexes
RewriteEngine On


3 - Make sure that you're using properly formatted expressions (for example, to redirect url from "/trails" to "/departments-development-details.php?Wilmot-Trails-4" you would use

Code
RewriteRule ^trails$ /departments-development-details.php?Wilmot-Trails-4


or to point calls to "/Test-5" to "/index/parody.php?Test-5" use:

Code
RewriteRule ^/([a-z]+)-([0-9]+)$ /index/parody.php?$1-$2 [NC]


NOTE: Adding [NC] to the end of the RewriteRule makes the expression case insenstitive (No Case)

The leading '^' and the trailing '$' anchor the expression you are looking for, in this case 'Trails' (so the string after the url contains only 'Trails' and nothing else) or 'Test-5' (the string after the url contains any number of letters followed by a dash followed by any number of digits - the actual letters and numbers are captured as variables in sequence ($1 and $2) and used to complete the redirect address - note that the '-' is still required as it is not captured as a variable).

4 - If you're getting 404 redirect errors, make sure that the page that you are redirecting to exists on the server (and that the page you are redirecting to has the leading '/'!)



Getting .htaccess to do what you want is always tricky and I can only recommend reading, testing and the more reading to get comfortable with using .htaccess files.

Another good resource for learning about .htaccess is http://www.easymodrewrite.com and the Apache docs at http://httpd.apache.org/docs/current/rewrite/.

Hope this helps!

Tom