i have the following redirect rule
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^$ /folder/
basically my index.html file is in folder.html and instead of copy and pasting the index.html file from /folder/ i was trying to use the rule above to request the file and output the file as mysite.com but instead it is redirecting to mysite.com/folder/index.html. I assume this is possible to do as frameworks use the rewrite rule and this doesn't redirect the browser. Can anyone advise on what i am doing wrong?
Thanks in advance.
Related
I need a question on how can I redirect .htaccess and .htpasswd file to 404 file?
Redirect /.htaccess /404.php
Redirect /.htpasswd /404.php
Doesn't work! :/
Whan should I need to put inside .htaccess file?
How Facebook redirects from .htaccess to a login page?Thanks in advance.
Well, although .htaccess and .htpasswd are block from httpd.conf, but if you want a redirect rule for any whatever reason try with mod_rewrite,
RewriteEngine On
RewriteCond %{REQUEST_URI} (.htaccess|.htpasswd)$
RewriteRule ^ - [R=404]
I want to use URL Rewrite to rewrite all requests on my domain to a subdirectory. But the visitor hould not see, that it is a subdirectory. I tried a view things, but nothing worked really good. Can you help me? In this subdirectory is also a .htaccess file and this file shouldn't be ignored by the server.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule (.*) sub-directory/$1 [L]
My question seems to be unanswered on StackOverflow, so here goes:
I want to rewrite the following URL using an htaccess file which is in the root folder.
The URL to rewrite is this:
http://www.domain.com/subfolder/item/12345
to this:
http://www.domain.com/subfolder/item.php?id=12345
However nothing I seem to do works. I can successfully rewrite the item.php URL if it is in the root folder using this:
RewriteRule ^item/(.*)$ item.php?id=$1 [NC,L]
... but not if the item.php file is in a subfolder!
You can use following .htaccess in your subfolder:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /subfolder
RewriteRule ^item/(.*)$ item.php?id=$1 [NC,L,QSA]
Your rewritten URL would become: http://domain.com/subfolder/item/123
Here is an example for sending this URL (The one entered in the browser address bar):
http://www.domain.com/subfolder/item/12345 (Can be any number) to this rewrited URL:
http://www.domain.com/subfolder/item.php?id=12345
RewriteEngine on
RewriteRule ^subfolder/item/([0-9]+)/?$ subfolder/item.php?id=$1 [L]
Those directives will work only if there is a subfolder directory and in that directory there is in fact a file item.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.
I'm in the process of testing a site at a preview URL until the DNS transfers over. I'm previewing the site at http://IP_ADDRESS/~name/.
All of my images that have been uploaded in the CMS are listed like <img src="/uploads/images/">.
But this doesn't work while i'm on the preview URL. So ideally I need to redirect /uploads/* to /~name/uploads/*
I was wondering if this should be a redirect or a rewrite in htaccess and what the rule might be?
Thanks.
This is the code you'll need in your .htaccess under DOCUMENT_ROOT:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^uploads/ ~name%{REQUEST_URI} [L,NC]