Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 20th Mar 2014, 06:28 AM   #1
Warrior Member
 
Join Date: 2014
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default
How to efficiently rename website URL's?
Share on: 
fb share twitter share gplus share more share

Lets say I'm creating a website about with 4 pages about bananas, apples, tomatoes and carrots, so I currently have 4 `.html` files: `bananas.php`, `apples.php` etc.

I suppose I would like to have `bananas.php` show as:

`domain.com/fruits/bananas-are-good/` (as I see many websites do it that way),

and `carrots.php` to show as `domain.com/vegetables/carrots-info/` and so on.

meaning I want to:

1. have a categorizing subfolder
2. not have any `.php` in the url
3. have a custom, longer name for each page.

What are my options and what is most recommended to achieve this?

I know I can manually create a folder in my domain's root folder named "fruits",
and then create a folder named "bananas-are-good",
and then upload bananas.php as index.php.

But I don't think this is what pro webmasters really do.

I suppose you might tell me there's an option to create an .htaccess rule that changes each ".php" in the url to a "/", but then I would still have to rename my `bananas.php` file to `bananas-are-good.php` on my computer/root folder, and I would still have to create the "Fruits" folder, which is not comfortable **in case I want to update all the .php files on my website at once via ftp** (as I would have to manually go to each subfolder, and upload the relevant files, instead of uploading everything at once) - what if I would have 20 folders? it would be exhausting and inefficient.

**I would also need to link the pages to each other, and I'm not sure how should they be linked?** would I have to use absolute url's? (like change the link in my `apples.php` from the current `<a href = "bananas.php">` to `<a href = "http://domain.com/fruits/bananas-are-good/">` .

I would also want to reserve the option to have visitors arriving to links like `mydomain.com/vegetables/carrots-info/?referrer=name` (In case that matters anything).

So what is the best all round solution? I'm hoping there's an easy, free, and quick solution that does not require complicated tech skills (nor install anything), and that would allow my to keep using FTP for updating the website, and not some sort of a web interface.

Thanks!
goonie is offline  
Unread 20th Mar 2014, 06:39 AM   #2
ɹoıɹɹɐʍ ǝʌıʇɔɐɹǝdʎɥ
War Room Member
 
RobinInTexas's Avatar
 
Join Date: 2008
Location: Texas
Posts: 2,138
Thanks: 243
Thanked 453 Times in 382 Posts
Blog Entries: 3
Default
Re: How to efficiently rename website URL's?
Share on: 
fb share twitter share gplus share more share

The easiest way to do it would be to install WordPress.

WordPress will structure things that way based on a very common permalink setting used by tens of thousands of sites.

Robin


...Even if you're on the right track, you'll get run over if you just set there.
RobinInTexas is offline  
Unread 20th Mar 2014, 06:42 AM   #3
Warrior Member
 
Join Date: 2014
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: How to efficiently rename website URL's?
Share on: 
fb share twitter share gplus share more share

Well, call me old school but I don't use WP for building my websites. Only Dreamweaver and that's it...
goonie is offline  
Unread 20th Mar 2014, 08:36 AM   #4
SJL
HyperActive Warrior
War Room Member
 
SJL's Avatar
 
Join Date: 2010
Posts: 133
Thanks: 11
Thanked 31 Times in 26 Posts
Default
Re: How to efficiently rename website URL's?
Share on: 
fb share twitter share gplus share more share

You need to look into "htaccess clean urls". I can post easy, ready to use example later if you want. But i don't have time at this second.

But one thing's for sure. None of the pro admins code every page totally from scratch these days. That ruins the whole point of php.

SJL is offline  
Unread 20th Mar 2014, 03:05 PM   #5
Warrior Member
War Room Member
 
Join Date: 2014
Posts: 21
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: How to efficiently rename website URL's?
Share on: 
fb share twitter share gplus share more share

if your using a decent php mvc framework like cake or codeigniter you can use named routes like such:

http://bakery.cakephp.org/articles/F...ting-explained

or

http://ellislab.com/codeigniter/user...l/routing.html
valvednd is offline  
Unread 20th Mar 2014, 07:48 PM   #6
Ferdiworks Warrior
War Room Member
 
joe ferdinando's Avatar
 
Join Date: 2005
Location: Spring Hill, FL , USA.
Posts: 590
Thanks: 82
Thanked 450 Times in 283 Posts
Default
Re: How to efficiently rename website URL's?
Share on: 
fb share twitter share gplus share more share

You can also use this method:

Code:
How to create SEO friendly URL in PHP.
my old url included in ? = %  but i want to create /services.php or /keywords.php
please suggest me code[/quote]

To create SEO friendly URLs all you need is a little file called .htaccess.


Step 1
Open up your text editor and type the following:
RewriteEngine On
RewriteRule ^([^/.]+)/?$ /index.php?page=$1

Save this as .htaccess and upload to your webserver.
If you type www.yoursite.com/example, the Apache web server will now interpret it as www.yoursite.com/index.php?page=example


Step 2
The SEO friendly URLs should work now, but you also need a PHP script that will include the subpages.
The following script is set to include all pages from a directory called "inc", but change it to whatever you like.

Note: This should be in your index.php file where the main content appear.
<?php
$page = $_GET['page'];
 
$def = "home";
$dir = "inc";
$ext = "php";
 
if (isset($page)) {
    $page = substr(strtolower(preg_replace('([^a-zA-Z0-9-/])', '', $page)), 0, 20);
    if (file_exists("$dir/$page.$ext") and is_readable("$dir/$page.$ext")) {
        include("$dir/$page.$ext");
    }
    else {
        include("$dir/error404.$ext");
    }
}
else {
    include("$dir/$def.$ext");
}
?>


Step 3
Change all internal links and replace them with your new SEO links.
For example, if you have a link to index.php?page=about, change this to about.

You're finished! Open your website and try to enter the short SEO friendly URL.

joe ferdinando is offline  
Unread 22nd Mar 2014, 03:50 AM   #7
varunteja
 
Join Date: 2014
Location: bangalore
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: How to efficiently rename website URL's?
Share on: 
fb share twitter share gplus share more share

thank u joe ferdinando for code
varunteja is offline  
Unread 30th Mar 2014, 05:01 AM   #8
Warrior Member
 
Join Date: 2014
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: How to efficiently rename website URL's?
Share on: 
fb share twitter share gplus share more share

I'm a little confused,
While my pages are .php, is it really necessary to use PHP in order to achieve the rewriting? isn't plain .htacess editing is enough?

Joe Ferdinado's example is relevant only for a case where all pages would carry a similar url pattern, whereas I'm looking to have url that look like:

.com/category/name
.com/category2/name
.com/category/name2
.com/name3

I don't want to use WP as all my site is already built with regular html/php, and I've heard WP also takes a lot of resources, so I wouldn't want to install it just for the sake of having nice URLs.

Yet I do acknowledge that it would be inefficient to code everything from scratch, so what's the best solution for me?
goonie is offline  
Unread 30th Mar 2014, 05:46 AM   #9
Ferdiworks Warrior
War Room Member
 
joe ferdinando's Avatar
 
Join Date: 2005
Location: Spring Hill, FL , USA.
Posts: 590
Thanks: 82
Thanked 450 Times in 283 Posts
Default
Re: How to efficiently rename website URL's?
Share on: 
fb share twitter share gplus share more share

Originally Posted by goonie View Post

I'm a little confused,
While my pages are .php, is it really necessary to use PHP in order to achieve the rewriting? isn't plain .htacess editing is enough?

Joe Ferdinado's example is relevant only for a case where all pages would carry a similar url pattern, whereas I'm looking to have url that look like:

.com/category/name
.com/category2/name
.com/category/name2
.com/name3

I don't want to use WP as all my site is already built with regular html/php, and I've heard WP also takes a lot of resources, so I wouldn't want to install it just for the sake of having nice URLs.

Yet I do acknowledge that it would be inefficient to code everything from scratch, so what's the best solution for me?
there are many ways to do what you want done!

so go to the pages you want in the category you like. get your pages and rename them to index.php or another name and put them in a category folder. each category main page will be index.php. So you can have a menu page and then sub menu pages!

OK you create your folders and name them what you like:
.com/category/
.com/category2/
.com/category/

then have your php files in each folder!
.com/category/index.php
.com/category2/index.php
.com/category/index.php

the index.php in each category can have there own links for anything within that category folder!

joe ferdinando is offline  
Closed Thread


Bookmarks

Tags
efficiently, rename, url, website


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 01:41 PM.