I am using codeigniter php framework. I am trying to access a folder under public_html, but I can't get to it. It shows 404 custom page by codeigniter. Does the following script in .htaccess has something to do with it?
RewriteEngine on
RewriteCond $1 !^(index\.php|js|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Thanks
It probably is, you can try adding either some conditions:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|js|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Or include your folder as part of the exclusion (example, your folder is "foobar"):
RewriteEngine on
RewriteCond $1 !^(index\.php|js|images|robots\.txt|foobar)
RewriteRule ^(.*)$ /index.php/$1 [L]
Related
I have created sub-domain like this in Codeigniter 3
www.test.example.com
I have used this .htaccess and it's working only home page.
www.test.exapmle.com for other pages like www.test.exapmle.com/page1 or www.test.exapmle.com/page2
.htaccess I used:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public_html/index.php/$1 [L,QSA]
I am getting this error:
the server encountered an internal error or misconfiguration and was
unable to complete your request.
In .htaccess file just insert the following code
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
i have a website that i made with codeigniter it works relativly fine on the local machine but when i uploaded it to the server it gives me a 500 error, and the error is gone when i remove the htaccess, and in the local machine the error appears in a different way some times i couldn't find what causing this but some urls get rewritten like this:
the original url => http://domain.com/controller/method
the rewritten url => http://domain.com/absolute/path/to/controller/method
here's my htaccess file:
RewriteEngine On
RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
RewriteRule ^(.+)/$ $1 [L,R=301]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
any help, thanx in advance.
try with my .htaccess code........
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I am using codeigniter. I have front end application and backend application like
/system/
/application/
/front/
/admin/
index.php
admin.php
.htaccess
I want my url like http://example.com/news/article1 (for site)
http://example.com/news/admin (for admin)
In .htaccess I have written
RewriteEngine On
# If the user types just "admin".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/admin$ admin\.php [L,QSA]
# If the user enter in any admin section, like "admin/section".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/admin\/(.*)$ admin\.php/$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
the front end is working fine but when I enter mydomain.com/admin it is throwing 404 not found error. Please help me.
Thanks and regards
I'm not that good with .htaccess, but from the CI website, you can use this for your .htaccess rule
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
and then use routes to rewrite your urls. Much easier than trying to do it in .htaccess files
So I'm using .htaccess to redirect old site pages to new site pages. A typical rule in my file looks like this:
Redirect 301 /faqs.php http://blueprintprep.com/classroom/faq
Strangely, it works fine when the old file exists on the server, but when I remove the file, the final URL actually looks like this:
http://blueprintprep.com/classroom/faq?/faqs.php
What in the blue blazes is going on??
The file is made up of a bunch of these rules and this for CodeIgniter:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^application_consulting/(.*) http://blueprintprep.com/oneonone/app_consulting [R=301,L]
RewriteRule ^weekend/(.*) http://blueprintprep.com/classroom [R=301,L]
RewriteRule ^workshop/(.*) http://blueprintprep.com/oneonone [R=301,L]
You can use mod_rewrite instead.
RewriteEngine on
RewriteRule ^/faqs.php$ /classroom/faq [L,R=301]
This will work regardless if the file exists or not.
Hope that helps.
I am trying to let the "trac" directory and all of it's subdirectories be accessible through the url http://www.domain.com/trac/
I am working with the codeginiter framework and my directory structure looks like
.htaccess
index.php
system
trac
I can access the abov url fine, but the problem is the scripts and other files contained in trac subdirectories ie: trac/chrome/common/css/trac.css are not accessible and 404. Here is my .htaccess code. Please help.
RewriteEngine On
RewriteRule ^$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond $1 !^trac/
RewriteRule ^trac/(.*) /trac/$1
You don't even need to mention /trac/ in your .htaccess. That's EXACTLY the point of
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
You're setting two "Rewrite Conditions." The first one says, "As long as the request isn't a file." The second one says "OR As long as the request isn't a directory."
Then
RewriteRule ^(.*)$ index.php?/$1 [L]
Sends everything else to index.php, where CI takes over. And just for the record, my full .htaccess that I use on every project:
Options +FollowSymLinks
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]
If you're confused about the RewriteCond %{REQUEST_URL} ^system.* line, it only exists so that any browser requests to the /system/ folder is always routed to index.php, and therefor ignored.
rewrite rules are executed in order... so try this
RewriteCond %{REQUEST_URI} !^/trac/
RewriteCond $1 !(index\.php/)
RewriteRule ^(.*)$ index.php?/$1 [L]
Explanation:
if the uri DOES NOT start with trac
if the uri IS NOT index.php
rewrite url as index.php?/{rest of the url}
If you remove the last two lines, it should work.
RewriteCond %{REQUEST_FILENAME} !-f checks to ensure that you're not requesting a file. If you are, this condition fails and the rule RewriteRule ^(.*)$ index.php?/$1 [L] is never executed.