My images are not loaded with Phalcon Framework.
Maybe because the .htaccess file. I don't know.
The framework return this error:
"ImgController handler class cannot be loaded", when access http://domain.com/img/tiger.jpg
The route "http://domain.com/projects/update/1" is OK.
My .htaccess files below.
#/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
#/public/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
What's worng ?
Thanks anyway.
It appears to be a routing problem, especially if something works and something isn't. Phalcon digests the uri, finds a route, but cannot dispatch the ImgController. Check that the naming is correct, that your have the correctly named controller (ImgController not ImageController), that it has the correct namespace. If doesn't help, add your routing configuration details and your ImgController and where it is located.
Related
All of my .htaccess in codeigniter like this
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
But all tutorial .htaccess are like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I need help to remove index.php url in codeigniter.
Why should I replace all code .htaccess like tutorial said ?
Should you replace all code .htaccess like tutorial said ?
Yes! just in the root directory of your CodeIgniter project.
Why?
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
The CodeIgniter documentation says that by the rules given in .htaccess file, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.
without these rules, for example, you'll have to access your login page like this
http://yourdomain.com/index.php/<controllerName>/login
with the rules in .htaccess file it's
http://yourdomain.com/<controllerName>/login
I'm running the most recent version of Symfony through Mamp. I have some image assets prefixed with /web/ in my code base. Symfony can't seem pull them up when I go to my local url (u.local).
An example image asset url would be (relative path): /web/productEditor/image.png
In mamp under additional parameters for <directory> I have:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
I can't change the local code to just remove the /web/ part of the img src tag. Is there a way to configure .htaccess to ignore the "/web/" part of the url?
Can I configure Symfony to differently through mamp?
Directory Structure:
Web Root
-Web Folder
--App.php (what boots up symfony)
--productEditor
---Assets
Thanks.
You question doesn't tell me where your app expect the images to be. if its looking for them in /productEditor/image.png in stead of /web/productEditor/image.png then the following may solve your issue. ( but i have not tested this )
RewriteCond %{REQUEST_URI} ^/web/
RewriteRule ^web/(.*)$ /$1 [QSA,L]
With the full .htaccess block you have listed above it would be.
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/web/
RewriteRule ^web/(.*)$ /$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
-Nathan
Here is my .htaccess for simple url rewriting for any MVC architecture.
Options +FollowSymlinks
RewriteEngine On
RewriteBase /personal/site/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Every thing is working only one exception rises. On the root where index.php exists i created a file generator.js, i also do have a controller named generator.
So for a request, http://localhost/personal/site/generator/css,
it must rewrite it to http://localhost/personal/site/index.php/generator/css
But it is rewriting it to http://localhost/personal/site/generator.js/css
How to resolve this scenario?
Turn off multiviews.
Options -MultiViews
I downloaded MyClientBase application which is based on code igniter. After the installation, I looked at the MyClientBase's website but the index.php is still there by default.
I tried to remove the index.php using the tips in codeigniter's user guide but it doesn't work.
Is there any solution out there for this issue? Thank you
I use the following .htaccess file to remove index.php. I'm not sure which one the user guide specifies, but I found this to be working perfectly:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|(.*)\.swf|images|robots\.txt|css|docs|cache)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
Also remove 'index.php' from your config.php file. Good luck!
i don't know if it will help but, i use this to remove my index.php from codeigniter url, create a file named .htaccess and put it to your codeigniter folder.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
Has anybody in the history of the internet and web development, been able to get rid of the "index.php" with mod_rewrite in codeIgniter.
I've been trying for several days now and nothing seems to work.
I'm using this one (in .htaccess file):
<IfModule mod_rewrite.c>
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]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Not sure where I got it but it works for my codeigniter install, local and live. Don't forget to set $config['index_page'] = ''; in your config file.
For mod_rewrite use the following in your .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
If your codeigniter instance is running in a subdirectory then use the rewrite base command before the RewriteRule
RewriteBase /subdirectory/
Then set
$config['index_page'] = '';
In the config file.
You might have your .htaccess file in the wrong place. CodeIgniter has a default .htaccess placed in the applications folder, which I mistakenly took for the one I should edit.
You actually need to create a new .htaccess under the root folder. So not code_igniter/applications/.htacces...but code_igniter/.htaccess
Hope this helps.
Yes, I configured it under Linux using the instructions from here. However, I configured it via httpd.conf instead of using .htaccess.
I have used the settings provided above and they always worked - unless I did not have mod_rewrite enabled.
If you are having issues check to ensure you have mod_rewrite enabled. If you do not it will not matter what you put into .htacess or your Apache config