Simple URL rewrite, not redirect, with .htaccess - .htaccess

I'm pretty inexperienced with .htaccess so please bear with me.
I have a domain - "http://www.exampletest.com"
which redirects to a folder at a different domain where I have hosting i.e:
"http://www.differenturl.com/exampletest"
Is there an easy mod_rewrite rule where I could have anything at "http://www.differenturl.com/exampletest" show up as "http://www.exampletest.com?" An example would be:
"http://www.differenturl.com/exampletest/user.php" -> "http://www.exampletest.com/user.php"
Any assistance is greatly appreciated. I assume this easy so sorry to ask such a basic question.
Thanks

You say "rewrite, not redirect", so no, there isn't a simple way to do this. The only way to do what you ask would be to have a "reverse proxy" running on www.exampletest.com that fetches content from "www.differenturl.com/exampletest/". That isn't something you can do with mod_rewrite.

If I have understood correctly, following code might do:
RewriteRule exampletest/(.*)$ http://www.exampletest.com/$1 [R=301,L]
Please note that you add this line in the .htaccess file placed on differenturl.com server.
Hope that helps.
Cheers

Related

.htaccess URL rewrite rules

I'm trying to learn how to rewrite URL's within htaccess files.
If anyone can give me some good links that would be brilliant.
I'm trying to aim to rewrite this:
http://www.domainname.co.uk/news/newsSingle.php?ID=9
to this:
http://www.domainname.co.uk/news/category-name/post-name.php
I have the category-name & post-name within the database for each matching ID.
Any help would be great thanks!
you can take a look at
9lessons.info
Media Temple
Stack Overflow .htaccess
Hope these help you find the answer.

Is this possible with an htaccess rewrite

I am wondering if this is possible to do with an .htaccess rule.
My beginning url:
http://cmfi.org/wherewework/missionary/?missionary=ttaho%2C
What I want to end up with:
http://cmfi.org/wherewework/missionary/ttaho
The ttaho will change according to the page.
Thanks for any input.
Don't think I was asking anyone to code this for me...Just asking if it was possible. I have tried a few things and couldn't get them to work. The %2c is an encoded part of the url that is added from the plugin I was using.
I will figure it out. No worries.

.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.

Creating Google Friendly Folders

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]

htaccess 301 wanted experts in htaccess

Question how do i rewrite
http://www.mywebsite.nl/support/department/index.php?/Ontruimingsvonnis/Knowledgebase/List/
to
http://www.mywebsite.nl/support/knowlegdebase/list
i have tried different ways to solve it but sofar no luck. Me and htaccess just aint friends.
Who will be able to help me out with this is need a 301 redirect for this one?
Could it also be that the index.php? would give a problem here?
Thanks in advance,
Paul
My Memory is a little hazy on this (its been a couple of years since i had to do this) but i believe mrewrite is what you need to use.
After a little digging, i found the page that might be helpful
http://www.workingwith.me.uk/articles/scripting/mod_rewrite

Resources