On production I have domain http://xxxx.com.
In root folder I added .htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]
</IfModule>
And when I type in the browser: http://xxxx.com it works.
The same .htaccess file I have on my machine. I use XAMPP. And it doesn't work. When I type:
http://localhost:8082/myfolder
I get 404. When I type:
http://localhost:8082/myfolder/public
It works.
What is the difference between url in my hosting and on my local machine?
For the first answer:
this is a screen, maybe I'm doing something wrong (.htaccess is in the root folder), maybe .htaccess in the public folder is wrong:
This should work for you:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteRule !^public/ public%{REQUEST_URI} [L,NC]
</IfModule>
The problem with your rule is that you're checking this condition:
RewriteCond %{REQUEST_URI} !^/public/
Which actually checks for URI /public from web root however you have your site inside a subfolder locally. Here RewriteRule !^public/ will check if public/ is not there at the start after the current directory context, which will work the same in site root as well in a subdirectory.
Similarly for rewriting also make sure you don't use / before public/ to allow it to use a relative path.
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 just moved old site of my client to some test server.
The site is on PyroCMS.
I've changed database settings in aplication/config/database.php and changed base_url in aplication/config/config.php to my test site URL.
Unfortunatly site is giving me 500 error and I don't have any error logs to see what else is to change.
Where I have to do changes to site run?
My .htaccess looks like this:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
#RewriteBase /wherever/pyro/is
# Keep people out of codeigniter directory and Git/Mercurial data
RedirectMatch 403 ^/(application\/cache|codeigniter|\.git|\.hg).*$
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
I use PyroCMS for almost all my clients and the same issue is in the default .htaccess file.
Try to remove:
Options +FollowSymLinks
And try to add:
Options +symlinksifownermatch -Indexes
Options -MultiViews
Many hosting disable +FollowSymLinks for security reason.
Make sure to set 775 permission to:
system/cms/cache
system/cms/logs
addons
uploads
assets
Also make sure to set your env to PYRO_DEVELOPMENT to see all the errors in this debug phase.
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 have codeigniter app in home directory. Sym link created in /var/www/html. I made changes to incldue .htaccess file in application folder to remove index.php in URL. The below link works fine.
http://mydomain.net/dms/welcome
That is, default method of controller works fine. But when I have method 'test' in welcome controller, the following link results in HTTP 404 webpage not found error.
http://mydomain.net/dms/welcome/test
Code igniter 2.1.1 directory:
dms
application
system
index.php
.htaccess
Config.php
$config['base_url'] = '';
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
Config file httpd.conf
Alias /dms/ "/var/www/html/dms/"
<Directory "/var/www/html/dms">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Sym links
ls -l /var/www/html
dms -> /home/user1/dms
.htaccess file
Options +FollowSymLinks -Indexes
Options -MultiViews
RewriteEngine on
<IfModule mod_php5.c>
RewriteRule ^([^/]*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^([^/]*)$ index.php?/$1 [L]
</IfModule>
I also tried with the following 2 Rewrite rules in place of above rules in .htaccess file.
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*)$ index.php?/$1 [L]
But contoller method cant be accessed without using index.php in URL. Having spent much time in this, I think it is something to do with Rewrite rules. Could some one guide me on this.
Please, test this configuration for .htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|.*\.css|.*\.js)
RewriteRule ^(.*)$ /angular1/index.php/$1 [L]
Replace "angular1" by your correct path.
I am trying to transform URLs from index.php to index.html, servicii.php to servicii.html and so on.
I wrote in my .htaccess file, which is in my site root the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.php$ $1.html [R=permanent]
</IfModule>
?>
But when I follow "Prima pagina" (Home) or "Servicii" (the only 2 pages created on site) it gives me a 404 error
Also, I have the code
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /fetesti/
RewriteRule ^(.*)\.php$ $1.html [R=permanent]
</IfModule>
on my local machine, which is XAMPP based. It gives me Object not found 404, and on my Apache log:
file not found [...]/index.html;
I know the rewrite engine is working (I wrote gibberish and it gave me 505 internal server error and made other tests)
What am I doing wrong?
Try just remove [R] permanent redirect, and switch extensions in rule
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php
</IfModule>