Add Folder Exception to htaccess File - .htaccess

I currently use the following .htaccess file that redirects every page on my site to the index.php page.
I would like to make an exception for my /images/ folder and all the files in it.
How can I ignore all of the files in that folder? Thanks.
RewriteEngine On
RewriteRule ^.*/$ /index.php [QSA]
RewriteRule ^.* index.php

try this instead of your :
RewriteEngine On
RewriteRule ^(images)($|/) - [L]
RewriteRule ^.*/$ /index.php [QSA]
RewriteRule ^.* index.php
or just create a new .htaccess file in the images derectory with this line in it :
RewriteEngine Off

Related

User friendly URL through .htaccess

My url looks like -
http://localhost/user_notes/?id=1234.
I want to be turn it into user friendly url like
http://localhost/user_notes/1234
My .htaccess file looks like -
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
RewriteRule ^(.+)$ /user_notes/?id=$1
</IfModule>
The problem is with RewriteRule ^(.+)$ /user_notes/?id=$1
For more info see my directory structure
Note : In my directory structure there is also a public folder. But I can access files without including public in URL through htaccess file (line 3).
Could you please place these rules at top of your htaccess file(I hope there are NO redirect rules for https in your htaccess file). Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^ public%{REQUEST_URI} [L]
RewriteRule ^(user_notes)/(.*)/?$ $1/?id=$2 [NC,L]

htaccess do not allow to access a file

This is my file structure. I need to get access to the images folder through a URL and get images. But I can`t access that folder. This is the URL that I need to get access. http://10.0.2.2/careuAppWeb/careu-php/images. I need to get pictures in the images folder and display it somewhere else.Is there any way that I can get access to that folder and get those images. I think the problem is my .htaccess file.
This is it.
Options -Indexes
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
How can I get access to Images folder.
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
You can change your mod_rewrite directives to something like the following instead:
RewriteCond $1 !^images
RewriteRule (.*) public/$1 [L]
This creates an exception for any URL to the /images subdirectory and rewrites everything else to the /public subdirectory.
The first RewriteRule you had was superfluous and is handled by the 2nd rule anyway.
This does assume you have an additional .htaccess file in the /public subdirectory that also contains mod_rewrite directives, otherwise you get a rewrite-loop.

modify .htaccess rewrite rule

I am new to web development. In my site I have public_html folder and it has the app folder. I have following RewriteRule in my htaccess file :
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
Now I want to modify the rule such a way that if I create new folder profile under public_html than it should display the index.php of the profile folder. Basically, If I type www.example.com/profile in browser window, it should display the content of index.php file.
There are a few ways you could do this, but this should be the simplest way for you.
RewriteRule ^[a-z0-9_-]+/?$ ./profile/index.php [L,NC]

Redirection to Desired Url

I have a url like:
http://x.x.x.x/~mmi/
which maps to the public_html folder on my site. I have installed cakephp on my site. The default htaccess file for cakephp looks like below:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I want to be redirected to:
http://x.x.x.x/~mmi/app/webroot/
instead of :
http://x.x.x.x/app/webroot/~mmi/
which is happening now. How should i modify htaccess file to get this desired result?
Following does the trick:
RewriteEngine on
RewriteRule ^~mmi/(.*)$ http://x.x.x.x/~mmi/app/webroot/$1

htaccess redirection exceptions

i have the following .htaccess
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?type=Navigation&action=$1
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?type=Navigation&action=$1
Options All -Indexes
which sends everything to index.php in the root folder. But in my structure i have something like
/root
/.htaccess
/index.php
/files
/intranet
i was wondering if there is a RewriteRule exception so that when i type www.mysite.com/intranet it goes to the 'intranet' folder without passing trough the index.php file
thanks!
Yes. I believe you just put a rule before the others with the url you do not want rewritten, and specify that it shouldn't be rewritten using - like so:
RewriteRule ^intranet/.*$ - [L]
RewriteCond %{REQUEST_URI} ^\/intranet\/?
RewriteRule ^([a-zA-Z0-9_-]+)\/?$ index.php?type=Navigation&action=$1 [L]
Will do the trick.

Resources