I have a codeigniter site http://piyukarts.in/mss/ where in .htaccess file under mss contains
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
# Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
but i cant access a link http://piyukarts.in/mss/posts, but i can access piyukarts.in/mss/index.php/posts, with this index.php/ after mss/
piyukarts.in/ is wordpress site, also having a .htaccess file
Please help.. thanks a ton in advance...
I made this change in .htaccess file and its working fine now.
RewriteEngine On
RewriteBase /mss
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
RewriteRule ^(.*)$ /mss/index.php?/$1 [L]
To answer:
can another .htaccess file can work in subfolder
is:
Yes.
.htaccess files in any folder in the file path tree to the file, will be applied to the file.
so file as /root/home/site/includes/css/horses.css the htaccess in any of those folders would be applied to the file horses.css .
Related
I'm basically trying to have everything that's not a file (.css, .js, .jpg, etc...) rewrite to index.php to create sym-links. The code I have in my .htaccess file works for my root directory and for a single subdirectory So. "localhost/" and "localhost/help" both work, but "localhost/help/article-27" does not work. The .htaccess seems to rewrite everything when I try to use that second sub-directory, including JS and CSS files. Does anyone know why that is? Here's my code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>
As darren mentioned as per the comments it's not required to have $1 !!.(gif|jpe?g|png)$ [NC]
This will work for all the levels and CSS files whether symlink / direct links.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>
I want to convert the URL http://localhost/project1/mvc/public/content/1 to the URL http://localhost/content/1.
I have my .htaccess file placed in the public folder that removes the index.php in the URL.
Options -MultiViews
RewriteEngine On
RewriteBase /project1/mvc/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Here's my directory structure:
Project 1
---mvc
-----app
-----public
I need help in the creating .htaccess file for this. What is the syntax for modifying the URL and which folder/s should I put the .htaccess file/s?
Thanks
You can use this code in your DOCUMENT_ROOT/.htaccess file (above a directory level of mvc):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!/project1/mvc/public/).*) project1/mvc/public/$1 [L,NC]
i have added my project on free hosting 000webhost and my all files are listed in public_html/ directory.
project is built in codeigniter.
i have added htaccess file at public_html/.htaccess which contains
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
but this does not working for me is there any issue in htaccess?
I use this (it works for me in both, locally and remotely):
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
You need to create a folder called "public" in the root rolder and sub-folders for css, js etc.
Sorry from all my htaccess is ok but i had an extra chracter in my base url which was causing problem.
Sorry again.
I am a newbie at codeigniter. I have my codeigniter installed at localhost/path/learn_ci.
I have followed all the steps given in the codeigniter wiki. Here is my .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /learn_ci/index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I've also changed the config file as required. But when I try to access
I get this error
"The requested URL /learn_ci/index.php/welcome was not found on this server"
I have double checked...the mod_rewrite module in Apache is on.
The RewriteBase solution also didn't work. Am I doing something wrong??
As others have said, make sure that AllowOverride is set to All in your apache config or your virtual host file.
Given the path that you have codeigniter setup in, your htaccess should look like this:
RewriteEngine On
RewriteBase /path/learn_ci
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /path/learn_ci/index.php/$1 [L]
Also, remember that any assets you are using (img, css, js, etc) are referenced either with the base_url() function or using relative paths. The root of your project is going to be /path/learn_ci.
I find that it is easier to create a virtual host and add an entry to my hosts file locally. This mimics real life much better.
Try:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
You can do the following:
First in config.php file set
$config['index_page'] = '';
Next, create a .htaccess file in the codeigniter root folder and add the following content:
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
Save the file. It should work.
You place the htaccess file in your root public_html folder in the same directory as index.php
Then remove /learn_ci from your htaccess file, just make it /index.php/$1
Check your apache config, it should be something like :
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
I thought to add my answere. My project base url is http://localhost/newproject/
I included htacess file in the newproject folder.
here is the code.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
then I change config file.
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
and every thing started to work. now nomore index.php file.
I have a url which initially http://web.com/index.php/home/funct/ and I want to change this by removing the index.php so that it becomes http://web.com/home/funct/
If you are using Apache server, create a file called .htaccess and put this in it:
<IfModule mod_rewrite.c>
RewriteEngine on
# If the file/dir is NOT real go to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>
Then just remove the reference to "/index.php/" from your links and when the server doesn't find "home/funct" it will go looking for "/index.php/home/funct".