/    Sign up×
Community /Pin to ProfileBookmark

301 redirection with an .htaccess

Hi everybody !
I want to make a 301 redirection with htaccess, but here is a little difficulty :
I know how to redirect ONE page to another page.
I know how to redirect ALL pages from a website to the index of another website.
What I want is to redirect all the pages from my old url to my new url, but not list all of them in the htaccess…
Exemple :
[url]http://myolddomain.com/story.php[/url] to [url]http://brandnewdomain.com/story.php[/url]

All the pages have the same name, site has the same structure, the only thing that changes is the url.
Is it possible to do a global redirect, that would redirect all the inner pages to the new inner pages on the new site ?

I looked through all the documentation I could find everywhere, but I couldn’t find help on this specific question.

Also, about my dear google-rank : I finally managed to get myself a 4 and I intend to keep it. Unfortunately, by moving my site to a new server and new domain, I’ll most likely lose it. Is it possible to keep the high google-rank my old pages had for the new pages ?

Thanks for your help !!!
Ness

to post a comment
Full-stack Developer

3 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayFeb 06.2007 — Should be able to use mod_rewrite:

<i>
</i>RewriteCond %{HTTP_HOST} ^myolddomain.com$ [NC]
RewriteRule ^(.*)$ http://brandnewdomain.com/$1 [R=301,L]
Copy linkTweet thisAlerts:
@Ness_du_FratauthorFeb 06.2007 — Thanks !

And now, what if I want to exclude some files from the redirection ? (some pictures, some pdf files, some css... For bandwidth reason, I prefer to leave them on this unlimited bandwidth server)
Copy linkTweet thisAlerts:
@Ness_du_FratauthorFeb 07.2007 — Ok, so my server is not allowing me to use mod_rewrite.

I had to move all site with this instruction :

Redirect permanent / http://newaddress.com

The problem is that there are a few pages and a few folders that I absolutely DON'T want to redirect... Big crash ahead if I do.

How can I exclude some folders and some files from this redirection ?

Or, more :

if the only choice is to redirect page by page, how can I redirect at least folder by folder ?

Thanks for your help !!!
×

Success!

Help @Ness_du_Frat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...