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]
Related
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]
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.
Let's say I have a domain www.example.com
Now I want that, at this domain, my index page or main controller of the CodeIgniter folder should open without the folder name and the rest controller pages also without the folder name.
From: www.example.com/folder
To: www.example.com
I am hosting my files on hostinger. I don't want to remove my folder and export all the structure to base public_html.
I want my public_html to contain my CodeIgniter folder.
Any help would be appreciated!
To setup codeigniter on a subdirectory, you could try the following htaccess rule :
Options +FollowSymLinks
RewriteEngine On
RewriteBase /YOUR_SUBFOLDER
RewriteRule ^$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php?/$1 [L]
Change the YOUR_SUBFOLDER above to whatever subdirectory name you have.
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
I'm using rewrite rules for nice URL's on my websites, the problem is, that I'm supposed to upload a new website and keep an already existing e-shop running. The e-shop is in it's own folder called "shop" in the "/www" directory on the server.
But now my .htaccess file is messing with the e-shop, although it's in the parent directory, how should I block it's effects in the "/shop" dir?
Here's the code:
RewriteRule ^shop/?$ shop/ [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?detail1=$1&detail2=$2&detail3=$3&detail4=$4 [QSA,L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?detail1=$1&detail2=$2&detail3=$3 [QSA,L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?detail1=$1&detail2=$2 [QSA,L]
RewriteRule ^([^/\.]+)/?$ index.php?detail1=$1 [QSA,L]
Thanks for any help, Mike.
Try adding this above all of your rules:
RewriteCond %{REQUEST_URI} !^/shop
Then add a .htaccess file to the /shop directory with just this in it.
RewriteOptions Inherit