Remove '/home' directory from URL - apache

People i got 'www.domain.com/home'. I want delete from name '/home'. Just on url should left 'www.domain.com'.
I tested .htaccess but this not works. I see server automatic delete 'index.html' from URL. Some rules works in my htaccess but the replacing a names in URL - not.
Somebody know how to delete '/home'? I just spent all morning to find solution, but nothing working...

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteRule ^home/?$ / [L,R=301,NC]

Related

Slashes with Apache URL Rewrite

.htaccess file with mod-rewrite rules exists at the .htaccess in the public_html folder
User goes to the URL http://www.thedomain.com/download/myfile
Mod-Rewrite rules should actually tell the server to access the URL: http://www.thedomain.com/download.php?index=myfile
How can I do this on an apache server without creating another directory named "download"?
I am getting problems with the normal procedure because of the slash.
Make sure you have multiviews turned off, mod_rewrite is loaded, and then add these rules to the htaccess file in your document root:
Options -Multiviews
RewriteEngine On
RewriteRule ^download/(.*)$ /download.php?index=$1 [L,QSA]
You can also add that in your vhost config but with a leading slash right after ^:
Options -Multiviews
RewriteEngine On
RewriteRule ^/download/(.*)$ /download.php?index=$1 [L,QSA]

htaccess - Script inside subdirectory

I have already one blog running in root folder and I want to test another one in a sub directory called "test".
How do I make all links point to example.com/test/login.php and not example.com/login.php ? I don't want to edit all links in my files, I want this one behave as root so later no need to change anything when I put it in production.
I assume it can be fixed with .htaccess crazy Rewrite Module but I haven't figured it out yet so please help save my time!
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your DOCUMENT_ROOT/.htaccess file:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} /test/ [NC]
RewriteRule !^test/ /test%{REQUEST_URI} [L,NC,R]
Reference: Apache mod_rewrite Introduction

Apache htaccess URL rewrite guidance please

aI have a site, that is mirrored across many domain names. Let's say there are 26 of them, and they are:
www.aaa.com
www.bbb.com
... etc ...
www.zzz.com
All these domains are virtual hosts that reference the same document root and hence obey the same htaccess file.
What I now want to do is turn off all of them except for three. I only want to keep:
www.aaa.com
www.eee.com
www.uuu.com
I want all the other domains to forward to www.aaa.com, including the full original URL parameters and query string.
How do I set up rewrite rules in my htaccess file such that the following 301 redirects will happen:
www.bbb.com/thispage/ -> www.aaa.com/thispage/
www.kkk.com -> www.aaa.com
www.eee.com (not redirected - keep processing htaccess rules below)
www.uuu.com/thispage/ (not redirected - - keep processing htaccess rules below)
I hope I have made things as clear and simple as possible!
Thanks for any help.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^(www\.)?(aaa|eee|uuu)\.com$ [NC]
RewriteRule ^ http://www.aaa.com%{REQUEST_URI} [R=301,L]

Apache - rewrite images to php file with .htaccess

I'm looking for a way to rewrite all my image requests from one folder into some.php file, while preserving the original image url (or partial path).
So,
example.com/folder/img/test.jpg
would be rewrited as something like
example.com/folder/some.php?img=img/test.jpg
(is this the best approach?)
I'm not familiarized enought witrh regular expressions, so I'll be very thankfull :)
note : I've tried some solutions before, none of them worked. ALso, I'm running Apache 2.0 under CentOS environment.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(folder)/(img/[^.]+\.jpg)$ $1/some.php?img=$2 [L,QSA,NC]
Make sure:
.htaccess is enabled
mod_rewrite is enabled
Your URL is http://example.com/folder/img/test.jpg
It sounds like you you want the filename of the image in the url to be included in the new php url, not the entire url. So something like:
RewriteRule ^folder/img/(.*[.]jpg)$ /folder/some.php?filename=$1
Considering what you mention in the comments and that the previous rules didn't work, I edited the message, this is what i have now.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(.*)\.jpg [NC]
RewriteRule ^folder/img/([\w]*\.jpg)$ folder/some.php?img=img/$1[R=301,L]
If folder is al variable, you can change that for (\w*) and add the reference in the right side of the rule.
Hope this helps.
Bye

Apache redirect directory to index.php

I'm trying to redirect a simple folder to /folder/index.php.
My URL looks like this : site.com/folder and I want site.com/folder/index.php.
Throught de web I only found the reverse way but I do want to see my index.php so that I can later use links like site.com/folder/index.php#344
My .htaccess located in /folder/ looks like this :
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/(.+)$ index.php
</IfModule>
And of course it doesn't work.
Maybe is apache ignoring my file ? Maybe some others .htaccess are interfering ? I have no idea since I'm new to apache...
Thanks for your help
You could just skip this mod_rewrite stuff and use mod_dir:
DirectoryIndex index.php
With that in the htaccess file in /folder, going to http://site.com/folder you will get served the contents of index.php.