Rewrite URL to optimize for search engine - url

I want a URL on the form
mypage.com/ID/Some-random-text
to load its content from
mypage.com/loadstuff.php?id=ID
Can anyone show how this is done?
I have looked on different SEO optimization websites but not been able to figure out how to do this particular trick.

You could use apache httpd URL rewriting for this.
RewriteRule ^/(.*)/.*$ /loadstuff.php?id=$1
Note this example is not tested. You can find out more here https://httpd.apache.org/docs/current/rewrite/intro.html
Other web servers likely have similar options.

Related

Easy and practical approach to change/re-write URLs in Yii

I've read pretty much everything about Yii, such as Ullmans book, the guide, on several forums and of course exploring the framework files. As I'm learning to program at the time I do however rely on pratical examples to connect with the theory and I can't seem to find any useful on the Yii URL part (almost all examples is about removing index.php or shorten the URL).
So I'm kindly asking anyone to give me a practical example on how to change e.g.
http://www.domain.com/Yii/index.php/programsgames/739
Into
http://subdomain.domain.com/?title-of-item/title-of-category/title-of-main-category/739
And perhaps discuss if it's best to change in CUrlManager.php or in .htaccess?
I could imagine that a lot that could benifit from this example as it includes a subdomain, an URL change and additions to in as well. Hope that I'm not way off!
To remove index.php you should add 'showScriptName'=>false, in urlmanager array in your config file.
For formating path maybe something like this could be used.
'http://<subdomain:\w+>.domain.com/<item-title:\w+>/<item-category:\w+>/<main-category:\w+>/<id:\d+>' => 'yourcontroller/youraction'

Adding text before the site url

Example:
You know the site about.com ?
They have a whole subset of url's such as: pottery.about.com
My question: How to get the "pottery" in front of the URL?
Anybody have some nifty mod_rewrite to do this?
Thanks!
David
Those are considered sub domains, you can set them up most of the time through any hosting company. Usually they dont charge you for them, but some do. They are very easy to setup and can be done quickly versus regular domain names.

joomla entirely custom url

I want to give entirely custom url to my article
something like: /games/2010/junee2010/6/Dexter%20the%20Game.html
Because I am move html based site to Joomla and I want to save same urls for Google.
What extension or custom solution I need to use?
There are a couple of good SEF extensions that can probably do it -
http://extensions.joomla.org/extensions/site-management/sef/10134
http://extensions.joomla.org/extensions/site-management/sef/10019
However, I am not a big fan of using SEF extensions, the built in SEF works pretty well. Unless you have hundreds of articles you are moving, I would use 301 redirects and let Joomla build the URLs the way it would normally. One less thing to go wrong.

Domains & Foreward Slash

This is rather difficult to explain so please bear with me.
We will be hosting 4 websites on our server and the plan is to have each site sit under its own domain:
site-a.com
site-b.com
sub1.site-b.com
sub2.site-b.com
Notice the two sub domains!
However, our client has asked if we can implement the following url structure instead of using subdomains:
sub1.site-b.com BECOMES site-b.com/sub1/
sub2.site-b.com BECOMES site-b.com/sub2/
Does this make sense so far??? So we are using forward slash as opposed to sub domains.
Can you advise on the best way to achieve this please?
Thanks for any help!
Dave.
Use Apache to remap the domains. It's probably your webserver, so it's probably the answer.
The docs are here:
http://httpd.apache.org/docs/1.3/mod/mod_alias.html#redirect
Match your subdomain and redirect to the appropriate folder, copying and carrying over the query string as appropriate.
JQuery probably won't help you.
This will depend on your hosting situation.
In IIS you can setup virtual directories for this type of behaviour.
You could also use JavaScript or server side redirects in sub1, sub2 etc folders.

Django, Rails Routing...Point?

I'm a student of web development (and college), so my apologies if this comes off sounding naive and offensive, I certainly don't mean it that way. My experience has been with PHP and with a smallish project on the horizon (a glorified shift calendar) I hoped to learn one of the higher level frameworks to ease the code burden. So far, I looked at CakePHP Symfony Django and Rails.
With PHP, the URLs mapped very simply to the files, and it "just worked". It was quick for the server, and intuitive. But with all of these frameworks, there is this inclination to "pretty up" the URLs by making them map to different functions and route the parameters to different variables in different files.
"The Rails Way" book that I'm reading admits that this is dog slow and is the cause of most performance pains on largish projects. My question is "why have it in the first place?"? Is there a specific point in the url-maps-to-a-file paradigm (or mod_rewrite to a single file) that necessitates regexes and complicated routing schemes? Am I missing out on something by not using them?
Thanks in advance!
URLs should be easy to remember and say. And the user should know what to expect when she see that URL. Mapping URL directly to file doesn't always allow that.
You might want to use diffrent URLs for the same, or at least similar, information displayed. If your server forces you to use 1 url <-> 1 file mapping, you need to create additional files with all their function being to redirect to other file. Or you use stuff like mod_rewrite which isn't easier then Rails' url mappings.
In one of my applications I use URL that looks like http://www.example.com/username/some additional stuff/. This can be also made with mod_rewrite, but at least for me it's easier to configure urls in django project then in every apache instance I run application at.
just my 2 cents...
Most of it has already been covered, but nobody has mentioned SEO yet. Google puts alot of weight on the URL itself, if that url is widgets.com/browse.php?17, that is not very SEO friendly. If your URL is widgets.com/products/buttons/ that will have a positive impact on your page rank for buttons
Storing application code in the document tree of the web server is a security concern.
a misconfiguration might accidentally reveal source code to visitors
files injected through a security vulnerability are immediately executable by HTTP requests
backup files (created e.g. by text editors) may reveal code or be executable in case of misconfiguration
old files which the administrator has failed to delete can reveal unintended functionality
requests to library files must be explicitly denied
URLs reveal implementation details (which language/framework was used)
Note that all of the above are not a problem as long as other things don't go wrong (and some of these mistakes would be serious even alone). But something always goes wrong, and extra lines of defense are good to have.
Django URLs are also very customizable. With PHP frameworks like Code Igniter (I'm not sure about Rails) your forced into the /class/method/extra/ URL structure. While this may be good for small projects and apps, as soon as you try and make it larger/more dynamic you run into problems and have to rewrite some of the framework code to handle it.
Also, routers are like mod_rewrite, but much more flexible. They are not regular expression-bound, and thus, have more options for different types of routes.
Depends on how big your application is. We've got a fairly large app (50+ models) and it isn't causing us any problems. When it does, we'll worry about it then.

Resources