Welcome Guest, Not a member yet? Register   Sign In
URL with no function
#1

[eluser]OJ[/eluser]
Hi Guys,
I am looking for a way to always present the links on my website as follows:

http://mysite.com/test.html
INSTEAD of http://mysite.com/functionname/test.html

Is this possible or Not or do I have to do some rewriting rules.
I will appreciate if anyone can help point me in the right direction
Thanks

OJ
#2

[eluser]jedd[/eluser]
[quote author="OJ" date="1236288814"]Hi Guys,
I am looking for a way to always present the links on my website as follows:

http://mysite.com/test.html
INSTEAD of http://mysite.com/functionname/test.html
[/quote]

Well, normally CI will present URLs in this format:
http://mysite.com/controllername/method/...arameter2/

With sensible naming of controllername and methods, you can keep this quite tidy without having to play with rewrites.

Is there a particular reason you want to use URLs that end in .html?

Have you read about the rewrite options?
#3

[eluser]OJ[/eluser]
I want to make my urls simple and SEO friendly.
Ending it with .html is not an issue for me but I just want to reduce the length of my url.
I read about th rewrite but it appears to be very complex.
#4

[eluser]jedd[/eluser]
Well, the example you've given is a bit limited .. but I'd suggest that if you only show methods, or the second interesting bit of the URL, as per this:
Quote:http://mysite.com/test.html
INSTEAD of http://mysite.com/functionname/test.html
.. you'll break the guideline of unique URL's, as you'll have a lot of problem keeping 'test' (etc) unique as far as methods within all your controllers go.

I haven't done much with SEO, other than to know that it's mostly a pseudo science practised by sites that need to attract more attention than they deserve (almost by definition). And that I can't see why consistently having an extra 5-8 characters in the URL would reduce the 'effectiveness' of those URLs.

If you really want the effect, you could just have everything run out of the index() method within each controller, and the controllername becomes 'test' in the above example - or you do rewrites.
#5

[eluser]OJ[/eluser]
This is my only concern with code igniter. It makes our URLs too long.
May be you need to read further on SEO, it is huge and has made a lot of difference in my sites.
When I use wordpress, I get very simple URLs but with CI, I have add all the slashes before getting to actual name of the page. I will be able to plan my site better if the method name can be omitted.

I have been able to write write some codes to get around multiple slashes for the method parameters but still stuck with having to put method name.

Any more thoughts on this is welcome
#6

[eluser]sophistry[/eluser]
http://ellislab.com/codeigniter/user-gui...uting.html
#7

[eluser]xwero[/eluser]
Wordpress has only one section : blog posts. If your site has one section then you can create wordpress like items easily.
Code:
$route['(.+)'] = 'main/index/$1';
When your site has different sections you better add another segment otherwise you need to go through all your section slugs to find the right content.

SEO is just white hat hacking of spiders. If you provide good content and you have enough backlinks your url can be as crazy as you want it to be. The people who write the spider code know that adding a file extension can just be a hack to get an higher ranking so sooner or later, maybe already, they don't give an higher ranking to those urls. And with all the url shortener services the url as a constant is fading.

Clean and hackable urls that the site's/app's public can use will be more rewarding than over SEO-ed urls.
#8

[eluser]OJ[/eluser]
Thanks guys! Just before the last post, I did it with the following:
$route['([a-z]+)-(.*).([a-z]+)']="home/showlink/index/$1";
You guys rock!!
I do understand the importance of content and you are right url is not the main issue.
I needed it for some site automation reasons!
Thanks everyone!!




Theme © iAndrew 2016 - Forum software by © MyBB