I need to change all the calls from example.com/files/ to example.com/app/files/ with out any redirection( URL redirection ).
calls maybe contain sub directories and css , js , png , jpg files.
like.
example.com/files/css/style.css
example.com/files/js/script.js
example.com/files/image/background.png
example.com/files/upload/prof/1.jpg
In the same time i needed to add this code too( codeigniter index.php removel ).
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Your htaccess should look like this
ErrorDocument 404 /index.php
RewriteEngine On
RewriteRule ^files/(.+)$ /app/files/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
Related
We are working php codeigniter framework, when we run project on the Localhost it works without any issue, but when we live it on the server then some button are not working properly.
When the user press the signin button then the page redirect to the Home page instead of redirecting to the User Profile page.
/*Htaccess File*/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^jp_sys.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^jp_app.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Options -Indexes
Try This Code in .htaccess works for me........
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
I have a website working on one server. I am changing hosting, so I created a website on another server for testing.
Everything seems to be working, except CSS. It is not loading at all. I have 777 for tmp folder and mod re_write enabled.
I can see all cached files except for CSS.
Please advise and help
This is my .htacess file in www
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This is my second htaccess inside app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
This is my third htaccess inside webroot
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
and the url is 23.236.49.24
Add this line:
RewriteBase /
under
RewriteEngine On
in the 3 .htaccess files
Create .htaccess file in webroot folder.
And paste this code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
I tried all solutions I found about removing index.php from the URL, but I still cannot make it work properly.
Problem:
the URL http://localhost/rc/index.php/person/find shows the correct page.
the URL http://localhost/rc/person/find shows the WAMP main page (without any image) like it redirects to the root's parent folder.
my configuration:
I created .htaccess is placed in my root directory (/www/rc/.htaccess) which contains the following code:
<IfModule mod_rewrite.c>
# Turn on MOD REWRITE engine
RewriteEngine On
#Remove index.php from the URL
RewriteBase /rc/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#Also tried the following lines without success
#RewriteRule .* index.php/$0 [PT,L]
#RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
# If mod_rewrite is not installed, fire 404 error
ErrorDocument 404 /index.php
</IfModule>
I have also set $config['index_page'] = ''; (in www/rc/application/config/config.php file).
You must put your rule before CodeIgniter's main rule.
Replace your current code by this one (your htaccess has to be in rc folder)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rc/
RewriteCond %{THE_REQUEST} \s/rc/index\.php/([^\s]+) [NC]
RewriteRule . %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
The answer was given by Justin Iurman in the comment of the first answer:
Are you sure mod_rewrite is enabled ? You can check it in your apache config
This can be enabled in httpd.conf file or from the WAMP tray icon.
I'm newbie with htacces..
I've file htaccess like this
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I called url like this without index.php it's work
http://localhost/url/
but when I try to call
http://localhost/url/controller/
and
http://localhost/url/controller/method/
the page back to xampp's home.
so what would I do? I want url without index.php.
thank you very much every advice.
Looks like you need something simple like:
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|media|favicon\.ico|ipadicon\.jpg)
RewriteRule ^(.*)$ /index.php/$1
I am using mod_rewrite in my .htaccess files to make cleaner looking URLs. I have two directories (subdir1, subdir2) that are folders created inside the root directory. They are not sub-domains. The .htaccess files reside in the three directories: root, subdir1 and subdir2.
The following .htaccess file resides in the root directory:
Options All -Indexes
ErrorDocument 404 /404.php
FileETag MTime Size
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(subdir1|subdir2)(/.*)?$ [NC]
RewriteCond %{REQUEST_URI} ^(.*)?$ [NC]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ /subdir1/ [R=301,QSA,L]
RewriteRule ^(.*)(\.html|\.htm)$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php [L]
</IfModule>
and this one is in the subdir1 directory:
Options All -Indexes
ErrorDocument 404 /404.php
FileETag MTime Size
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdir1/
RewriteRule ^(.*)(\.html|\.htm)$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php [L]
</IfModule>
Everything is working fine. I can browse the www.mydomain.com/subdir1/1234-myaritcle.html page and read its content, but sometimes the rewrite module turns off without creating the clean URLs and the article opens with the following url: www.mydomain.com/index.php?article=1234
Can you please help? What is the cause of the problem?
Is there something wrong with the .htaccess files?
Nothing in your rules is causing the url to appear as www.mydomain.com/index.php?article=1234. Whatever link you are opening the article with is probably not generating the clean URLs.