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
Related
I change the index.php file path public to root. After adding a .htaccess file in the root path (laravel 5.7) every page working fine. But in laravel 5.8 when I click another page, it's showing 404 Not Found.
My .htaccess file is below.
<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>
The content of a Laravel .htaccess file should look like this:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Your webroot has to be set to the /public directory. Don't try to search for other solutions that move the index.php and .htaccess file from /public to the root directory of your Laravel application. There is absolutely no reason why you want to move the webroot from /public to /. index.php sits in /public for a reason. If your webhost does not offer the ability to move the web root to another directory switch your hoster.
It might be that you have created your folder as Example and trying to access it via example
ie
localhost/Example/public
yet accessing it like
localhost/example/public
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
I am using Codeigniter.I just need my url to be look like this http://example.com/ instead of http://example.com/myCodefolder/. My installtion structure is like "public_html/myCodefolder/" where could I change.
Method 1
You just move all the files from myCodefolder to public_html folder.
Here you dont need the myCodefolder.
Change the base_url() as http://example.com/
Method 2
Create an .htaccess file in myCodefolder and put the code,
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /myCodefolder/index.php/$1 [L]
</IfModule>
This may helps you
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.
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]