URL rewrinting from www.example.com to www.example.com/beta - .htaccess

His friends, currently my website is set up in the "beta" folder in my root just like
www.example.com/beta
Now if any user enters the following URL
www.example.com
then he should be automatically redirected to the first URL, any ideas? I know this can be done through .htaccess but i am not sure about it :( help me please. thanks

You'll find a good example of what you want right up at the top of When Not To Use Rewrite, which is a page everyone should read before they edit one character of an .htaccess file.
RewriteRule ^/(.*) http://other.example.com/$1
# is better expressed as..
Redirect / http://other.example.com/
Or, in your case,
Redirect / /beta/

Try adding
Redirect 301 / http://www.example.com/beta
to your .htaccess file in the root directory (untested)

Actually you can do it pretty simple (no .htaccess modification required).
Edit the headers of index.html file from your server main director (/).
Within the <HEAD> ... </HEAD> section add your redirection code, for example:
<meta http-equiv="refresh" content="0;URL=http://www.example.com/beta/somepage.html" />
Note that this should be located inside index.html of you main dir /.
For references see: http://devmain.blogspot.co.uk/2013/06/html-auto-redirect-website-to-different.html
Hope it help.

Related

.htaccess redirect within root directory

I have copy and pasted the new index.html file I made into the old one. However, I need to now redirect users from the old .html files to the new index page which has anchor links. I have seen 301 redirects online but none of the examples included items that were in the same folder on the same domain. I tried to use the following, in a .htaccess file, but it didn't work.
//301 Redirect Old File
Redirect 301 /about_us.html #AboutUs
Redirect 301 /contact_us.html #GetQuote
Thanks in advance!
You simply need to prepend the target paths with a leading slash:
Redirect 301 /about_us.html /#AboutUs
This will redirect /about_us.html to /#AboutUs.
If you omit the leading slash, then Apache will mistake the target path for a comment, and throw an Internal Server Error.
You may need to redirect people to a different page because a URL has changed. Redirect to a Different URL using the Meta Tag "Refresh".
<meta http-equiv="refresh" content="0;URL=http://www.example.com/new-index.html">
You can change the amount of time that this redirecting page is displayed by changing the number in the refresh content="5 portion of the meta tag statement.
<meta http-equiv="refresh" content="5;URL=http://www.example.com/new-index.html">
Note that meta tags go in the <HEAD> </HEAD> section of the HTML
document.
You can also use this line of code Apache .htaccess redirect.
# Permanent URL redirect
Redirect 301 /web/old-index.html http://www.example.com/web/new-index.html
Hope this will help to resolve your issue !!

Redirect custom URLs via htaccess

I have my own domain:
http://cesarferreira.com
and I wanna make
http://cesarferreira.com/github
point to
https://github.com/cesarferreira
Without having to make a /github/ folder with an index.html with a redirect for each page I own (facebook, twitter, pinterest, etc)
Is there a way like for example htaccess catchig *.com/github and pointing to a given static url?
Thanks a lot
If your document root serves -
http://cesarferreira.com
you can put a redirect in .htaccess like -
Redirect /github https://github.com/cesarferreira
Take a look at URL rewriter 'http://httpd.apache.org/docs/2.0/misc/rewriteguide.html'. That should be able to do everything you want and more.
As long as it is enabled in apache then you can use it in .htaccess files also.
You can use mod_alias:
Redirect 301 /github https://github.com/cesarferreira
Or if you only want github to point only to the folder:
RedirectMatch 301 ^/github https://github.com/cesarferreira
You can put that in the htaccess file of your document root.

RedirectMatch issue (redirecting folder, but not contents inside folder)

I have tried this every which way I could, but am not getting any love. I am attempting to redirect a subfolder in the site to just a static page. But I do NOT want to redirect anything ELSE that is inside said folder.
I have tried using the regular redirect 301, but of course that redirects everything in the subfolder.
To sum up: I want to redirect http://www.domain.com/folder/ to http://www.domain.com/foldername2/file.php without redirecting anything else inside /folder/.
The following is what I have in my htaccess... but... it is just ignoring it completely.
RedirectMatch 301 ^/folder$ http://www.domain.com/foldername2/file.php
Thanks in advance for help.
Instead of relying on HTTP, you can use a nearly empty index.html file which contains a <meta> refresh tag in the head section of the document.
The wikipedia article on meta refresh has some good examples, e.g.
<meta http-equiv="refresh" content="0; url=http://example.com/">
The 0 means "zero seconds"—that is, immediately.
After much struggling, I found the answer! It does not use the RedirectMatch, however. It uses a rewrite condition and rule instead.
RewriteCond %{REQUEST_URI} ^/folder/$
Rewriterule ^(.*)$ http://www.domain.com/foldername2/file.php [L,R=301]

using htaccess how can I specify index.html as the home page with both index.html and index.php on the server?

As my title says, using htaccess how can I specify index.html as the home page with both index.html and index.php on the server ? I have a regular basic html site on the server and I want to start working on a joomla site which of course uses php. I don't want to redirect the php if I enter in the index.php into the address to allow me to start working on the joomla installation. I just want to automatically go to index.html when the domain name is entered. I hope I'm making sense. Thanks
You use DirectoryIndex to specify, which file is shown, when just the directory is requested
DirectoryIndex index.html

htaccess redirect index.php?v=1 to index.html

I am trying to redirect this page /index.php?route=common/home to index.html
and have put this in my .htaccess page:
Redirect 301 index.php?route=common/home index.html
However, I get a 500 Internal Server Error when I do this.
Does anyone know how to do this correctly?
(Note: there are other pages example /index.php?route=checkout which I don't want to redirect)
Any help would be greatly appreciated.
Thank you
Redirect is just really used to make aliases (and is part of mod_alias). Instead, you need to use mod_rewrite, so RewriteRule /index.php?route=common/home index.html [R=301] should work, but check it first.

Resources