Need to show index.html in my url - .htaccess

Need to know how to show the full URL of my website, I would need to pass:
www.ejemplo.com.ar to www.ejemplo.com.ar/index.html
I've tried all types of redirect and rewrite, but none worked out. I hope you can help me.
Over Apache2

This is a pretty easy solution, a search would have revealed it easily. Try this.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?ejemplo\.com\.ar$
RewriteRule ^$ http://%{HTTP_HOST}/index.html [L,R=301]

Related

Redirect URL Using ".htaccess"

I am having a issue redirecting my URL to another URL. I have tried 4-5 ".htaccess" codes but they were not helpful.
I want to redirect "m.onlinedealsindia.in/?page=0" to "m.onlinedealsindia.in/?page=1".
Hope to get a helpful answer.
Thank you.
You can use this rule in root .htaccess:
RewriteEngine On
#RewriteCond %{HTTP_HOST} =m.onlinedealsindia.in
RewriteCond %{QUERY_STRING} ^page=0$
RewriteRule ^/?$ ?page=1 [L,R=302]

Internal Redirect blog/article.php?id=1 to blog/article/1

I have a blog folder in the public_html folder on my server with godaddy.
The .htaccess (in public_html) :
RewriteEngine on
Options +FollowSymlinks -Multiviews -Indexes
RewriteBase /
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{THE_REQUEST} /blog/article\.php\?id=([^\s&]+) [NC]
RewriteRule ^ blog/article/%1? [R=302,L]
RewriteRule ^blog/article/([^/.]+)/?$ /blog/article.php?id=$1 [L,QSA,NC]
The page takes me to 404 page on my online host with godaddy but it works fine on localhost.
I also tried:
RewriteCond %{QUERY_STRING} (^|&)article\.php\?id=(.*)(&|$)
RewriteRule ^(.*)/article.php$ $1/article/%1? [NC,L]
but that didn't do anything.
Please help!
Figured it out. For anyone that might run into the same problem, here is the simple solution:
Make sure that your tag contains the real url.
What I did was, I put the custom url in the tag and godaddy was not recognizing it.
So what I did was
article 1
instead it should be
article 1
That way it will redirect to the custom url correctly.
Hope that helps!

Hide subdirectory urls with htaccess

I'm sure some way or another this question is as old as the method itself but my challenge was to make
site.eu/subfolder/subfolder appear as subdomain.site.eu
I managed to figure that out on my own and got it to work. The code is following:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.site.eu [NC]
RewriteRule ^(.*)$ /subfolder1/subfolder2/%{REQUEST_URI} [R=301,P,NC]
The following issue is that in that adress, there is an app where you must log in.
After logging in, it will show subdomain.site.eu/subfolder1/subfolder2/content1
I have tried about 2-3 days to fix this but to no avail. I really hope somebody could help me out on this. IF there is any other info needed, please tell.
You can use this in root .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.site\.eu$ [NC]
RewriteRule ^((?!subfolder1/subfolder2/).*)$ /subfolder1/subfolder2/%{REQUEST_URI} [L,NC]

how to redirect www url to non-www url with htaccess?

I wanted to know how to redirect users from http://www.mysite.com to http://mysite.com using htaccess, I'm not familiar in how to manipulate this file in order to do this, can anyone help me accomplish this?
Thanks in advance.
This site gives a complete answer:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://domain.com/$1 [R=301, L]
It was the first thing that appeared when I googled for it, so I assume you didn't even bother to look for an answer (naughty boy, tsk, tsk!).
This site should be helpful:
http://enarion.net/web/htaccess/redirect-www-and-no-www/
Just add this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule (.*) http://mysite.com/$1 [R=301,L]
something like this should do the trick
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^www\.(.*)$ $1 [NC]
you want to google for "htaccess rewrite" to find more info about it

How can i get my htaccess to work (subdomains)?

I'm sorta a noob at these things but I'm trying to make a simple virtual subdomain with .htaccess. I have wildcard enabled and after lots of digging, this is what I've come up with:
rewriteEngine On
rewriteCond %{HTTP_HOST} !^$
rewriteCond %{HTTP_HOST} !^(www\.)?khpedia\.com$ [NC]
rewriteCond %{HTTP_HOST}<->%{REQUEST_URI} ^(www\.)?([^.]+).*<->/([^/]+) [NC]
rewriteCond %2<->%3 !^(.*)<->\1$ [NC]
rewriteRule ^(.+) /%2/$1 [L]
My directory is setup as
-root
--wiki
----index.php
--test
Right now when I travel to wiki.khpedia.com, I get a page not found. When I travel to wiki.khpedia.com/index.php, it travels to wiki.khpedia.com/wiki/index.php. I am somehow also able to access wiki.khpedia.com/test. If it doesnt seem obvious yet, I want to be able to go to wiki.khpedia.com/index.php and see wiki.khpedia.com/wiki/index.php but not in my address bar. Sorry for the text block and thanks for the help.
This works on the Apache side:
RewriteCond %{HTTP_HOST} !^www\.khpedia\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(.+).khpedia\.com$ [NC]
RewriteRule ^(.*) /%1/$1 [L,QSA]
But you're wiki software might make up it's own mind about redirects / urls.
RewriteCond ^(.*)$ /wiki/$1 [L]
I'm confused about where subdomains come into your question. Could you give some examples of URLs you want to access in the browser and what they should point to at the server?
EDIT | Ah, I see now, Wrikken's answer handles the subdomains correctly :)

Resources