Drupal - Redirect just the homepage - apache

due to internal politics with a project I need to redirect only the homepage of a site built in drupal to a different url. I want to be able to access the rest of the site to show people but just that when it goes to the homepage it redirects you.
I want to create a copy of the homepage and then have the original homepage automatically redirect to the new url....meta refresh wouldnt work because there is lag time...
Anyone know how to do this with .htaccess ?
Thanks
Add new comment

You can try adding this rule as first rule:
RewriteRule ^$ /new-home-page [L,R]

Related

Apache redirect if there are two directories in URL

I have a site where there are user accounts and pages for the public.
I would like to be able to access a users account with a URL like
http://mySite/theUserName
and access the back pages with
http://mysite/page/pageName
I have a RewriteRule currently that looks like this which works for redirecting the page.
RewriteRule ^page/(.*)/? /application/pages/getPage.php?page=$1 [NC,L]
How ever if you try and access a user account it still runs the rule as the rule doesn't know a page name was not given.
So how do I run the rule only if both "page" and "pageName" are provided and ignore it otherwise.
I guess another way that would not be as clean but would work is only run the rule if the first directory is "page"
Thanks for any help you can provide.

.htaccess RewriteRule not redirecting to the correct place

We found hundreds of 404 in one of our blogs, the previous team, deleted a lot of tags and articles. We are trying to create a 301 that redirects anything with /blog/forums in on WP app to WP /knowledge a different WP.
We have many instances like
blog/forums/topic/native-property-window/
blog/forums/user/hemo2/
blog/forums/topic-tag/wql/
We need the redirect to work no matter whats after blog/forums
and redirect them to
/knowledge
Any suggestions?
To redirect anything starting with blog/forums/ to /knowledge is pretty simple
RewriteRule ^blog/forums/ /knowledge [R,L]

redirect old url to new one in open cart

I looking for some help to solve this issue. i'm using open cart and made a product long time ago, of course i'm used SEO url for this product.
Ex. example.com/myproduct
but now i decided to change this url:
Ex. example.com/newproduct
it's now working and up in new url but google indexed that old url and i trying to redirect that old url to new one but no success.
first i tried mod_rewrite:
RewriteRule ^myproduct$ https://example.com/newproduct [R=301,L]
it's not working, then write with old method, 301 redirect:
Redirect 301 /myproduct https://example.com/newproduct
it's look like redirected but there is a problem, when i run that old url it redirect to new url like this:
example.com/newproduct?route=myproduct
it show 404 page not found. but if i using fake url for example:
Redirect 301 /oldtest https://example.com/newtest
it's working fine! i'm wondering why it's not working!
I suggest this is because OpenCart is handling it and interfering with what you are doing. Use your first idea:
RewriteRule ^myproduct$ https://example.com/newproduct [R=301,L]
But make sure it is at the top of your .htaccess file before anything else from OpenCart. Make sure it has RewriteEngine On before it.

I wanna stop direct access to and folder using htaccess

I wanna set up an download page.
I need to access those pages only through a login page and stop all the direct access to the download page path and also its files and again if anyone tries to access those pages directly then it should automatically redirect to login page itself or else at least with a 404 error.
How can I do all these in .htaccess file. It will be very much helpful in developing my website.
Thanks in advance
Assuming that your all of your downloads are inside of a downloads directory, something like this should do the trick.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^https?://(?:www\.)?your.site.*
RewriteRule ^downloads\/?.* http://your.site/login [R=302,L]
Alternatively (and ideally) you should instead keep the pages outside of the site's root directory and download them through a proxy page.

Proper 301 redirect for sites

I have a bit of a complex question. I am moving sites from
http://www.hikingsanfrancisco.com
to
http://www.comehike.com
The directory structures will not be the same throughout both sites. What are some of the best practice things I can do in order to retain most of my existing SEO strength in both the general domain and individual pages for searches related to the other pages?
Thank you,
Alex
If most of the URLs are staying the same and just the domain is changing, you could create an .htaccess file in the root folder at the old site with the following:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.comehike.com/$1 [R=301,L]
This will make hikingsanfrancisco.com/some-page go to comehike.com/some-page.
Otherwise in that same htaccess file you could add a line for each redirect. So if hikingsanfrancisco.com/big-hikes is now going to comehike.com/even-bigger-hikes the redirect would look like:
Redirect 301 /big-hikes http://www.comehike.com/even-bigger-hikes
That 301 tells Google to now consider the new URL correct.
To redirect the whole site no matter what to the new URL you could use this:
Redirect 301 / http://www.comehike.com/
A 301 Redirect, page by page, is the best option (If you can use regular expressions is easier). Redirect the old page to a page in the new site with similar content.
Use the change of address tool in Google Webmasters tools.
Try to contact some of yours referrals to change the links that target your site.