Creating Google Friendly Folders - .htaccess

Basically I'm trying to figure out a way to make
http://www.mysite.com/check/google.com
show the contents of the page
http://www.mysite.com/check.php?site=test.com
and I want users to think that the actual URL is http://www.mysite.com/check/google.com instead of the long one.
But I need to do this in the friendliest way for Google so that they aren't looking at it as a redirect and it'll still rank well... Any help will be greatly appreciated if you can post some sample code... Thanks!

In the htaccess file in your document root, try adding:
RewriteEngine On
RewriteRule ^/?check/(.*)$ /check.php?site=$1 [L]

Related

.htaccess to change the url path

I have tried several examples of solutions that I have found here on StackOverflow but none of them seem to work correctly.
I have a Magento store that I need to redirect an old store code url to the new one. For example:
The old url looked like this.
www.example.com/something_en
In the above example I need to be able to modify any url that contains to the path something_en and change it to something like in the next example.
www.example.com/something
Any help is much appreciated.
Make sure this is your very first rule in main .htaccess:
RewriteEngine On
RewriteRule ^something_en(/.*)?$ /something$1 [L,NC,R=301]

.htaccess rewrite help request

I am hoping to gain some help with a small trouble I am experiencing with configuring a .htaccess file. Basically, I want to retrieve 2 variables from a URL String.
For example:
If someone entered www.website.com.au/folder/category/item.php
I would like the .htaccess to retrieve the last two variables (being Category and Item) and parse them to my display-item.php page.
I have a rough idea of what I need to be doing (As per below) though with all the tutes I have been reading I am a little confused.
Any help would be greatly appreciated.
:) Paul
RewriteRule /folder/(.*)/(.*).php /folder/display-item.php?category=$1&item=$2 [L]
RewriteRule ^folder/(.*)/(.*).php /folder/display-item.php?category=$1&item=$2 [L]
Works a treat. Managed to get it working.

Rewrite many URL's to another directory while altering the filenames

What I'm trying to do is rewrite something like
http://www.example.com/folderA/aaa_bb_cc_ddd.php
to
http://www.example.com/folderB/aaa-bb.php
...and I'm have just an awful time figuring out how. Any help or a point in the right direction much appreciated.
This is really going to depend on what these many URL's look like, but for starters you can try this in your htaccess file in your document root:
RewriteEngine On
RewriteRule ^/?folderA/(.*)_cc_ddd\.php /folderB/$1.php [L]
The trick here is figuring out what (.*)_cc_ddd\.php needs to look like. It's entirely dependent on this list of many URL's that you need to alter.

Why can't I make my URLs rewrite in my htaccess file?

I've been messing with this for the last hour... visiting about 20 different Google tuts and I can't seem make my site rewrite the url in any way. I've even just tried changing .php to .html and I'm not having any luck.
Here's one of my many fails:
RewriteEngine on
RewriteRule viewItem(.*)\.htm$ /viewItem.php?id=$1
For this above one, I'm just trying to change my viewItem.php page to viewItem.html
My ultimate goal is to change hxxp://mydomain.com/viewItem.php?id=900 (as one example of an id) to hxxp://mydomain.com/details/
I'm then going to append the title on the end. I can do the append in php but being a newb to .htaccess, I'm apparently missing something glaringly obvious.
Any ideas?
Thanks much.
Did you miss the 'l' of 'html'?
RewriteRule viewItem(.*)\.html?$ /viewItem.php?id=$1

How to rename /page.php?1 to /welcome.html in htacces?

I have a cms that does not generate friendly url's
What is the best way to rename this without getting double content by google.
Now I have in .htacces:
RewriteEngine On
RewriteBase /
RewriteRule welcome.html page.php?1[L]
RewriteRule about-us.html page.php?2[L]
Is this the best way to do?
Any help would be appreciated
Google has no problem spidering and indexing this very simple dynamic URL scheme. But if you want extra onpage-optimization-bonus-points with the help of keyword-stuffed-URLs it would be best you switch to a CMS that creates them automatically. You save time by avoiding to maintain the link-scheme manually both in your content and the rule-file.
If not there's always the chance you forget to replace those dynamic links with your readable ones if you create new content. Also your cms will always answer both variants: the friendly one and the dynamic one, so you have to tell Google the "canonical" URL (Explanation here) to avoid duplicate content. This might happen because you can't tell how people link to content on your site.

Resources