i'm new, and wanna try MVC pattern which is need to using .htaccess rule.
I have .htaccess file within both folder that listing below.
this is the rule that i used to .htaccess file in app/ folder:
Options -Indexes
and this is the rule that i used to .htaccess file in public/ folder:
Options -MultiViews
RewriteEngine On
RewriteBase /mvc/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
in the app/ folder the htaccess file works where its folder access is forbidden, but not for the public/ folder since the public/ folder is not listed.
can someone tell me why this happended ? and how to solve this?
hope you are not confused with my explantion and sorry for my bad english
thank you before
It's Solved, i forgot to enable mod rewrite,
so i just run this command
$ sudo a2enmod rewrite
Related
A development proyect in http://localhost/myfolder has references to /assets/css/styles.css which is the site in production.
I want to call it like: http://localhost/myfolder/
I have this .htaccess in apache webroot folder c:\wamp\www:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /myfolder/$1 [L,QSA]
And it works ok when is, as I said in webroot folder.
When I move this .htaccess to /myfolder/.htaccess it does nothing.
What I have to change in this .htaccess to work also inside myfolder?
Thank you
Because it's imposible to manage absolute paths refereds to root from a subfolder (as Anubhava said), I decide to focus the problem with an /.htaccess and a RewriteCond that work only when we request the specific subfolder.
SOLUTION: (/.htacces finally is in root folder).
RewriteEngine on
# ConfiguraciĆ³n Myfolder
RewriteCond %{REQUEST_FILENAME} !-f
# Fix is the line below ---- FIX ------
RewriteCond %{REQUEST_URI} ^/myfolder/.*$
RewriteRule ^(.+)$ /myfolder/$1 [L,QSA]
In the other way, without the rewrite condition, it was affecting all requests.
This is better fix than the subfolder one, because you can download the production .htaccess and have no need to touch it.
Hope this help to others.
This is my second Silex project, the first works fine. It is a one-page website with multi-language and twig support. Only multi-language doesn't work because nothing but the root route works. Not even $app->error().
The domain is dev.domainname.com/projectname/
The Directory Structure is:
/var/www
projectname
application
web
index.php/.htaccess, etc...
And this is my .htaccess
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /projectname/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
</IfModule>
The rewrite module is loaded according to apachectl -M | grep "rewrite"
Edit I forgot to mention that the application is stored in /var/www/... but the document root for dev.domainname.com is actually in a deeper parallel folder, and there is a symbolic link to the folder. Not sure how relevant this is.
I have the .htaccess script:
DirectoryIndex index.php
Options -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php [L,QSA]
which will redirect all requests into the index.php script, except for existing files or directories that exist. However, I have the directory /lib which contains the libraries for the webapp, and I would like to extend the rewrite rule to redirect requests to /lib[/(.*)] (the directory and everything under it) into index.php as well, but so far, I have been having issues.
What lines do I need to add to my .htaccess file to add support for that rule?
p.s.
The webapp that I am doing this for currently exists on a test server, and is all stored under a higher base, so the lib URL at the moment is http://localhost:8080/c2/lib. I have not defined the /c2 part in the .htaccess as I am trying to keep it disparate, and only have the webapp do the processing.
I am aware that I could just move the /lib directory into a higher directory, but I am trying to do this with .htaccess.
You can add an additional rule, which rewrites all requests for /lib/*
RewriteRule ^lib/.*$ index.php [L]
I have a directory structure like below.
public_html/
/abc/
/xyz/
/pqr/
there is a index.php in each these directories, abc,xyz,pqr.
now whenever is there any request like domain.com/abc/def/ghi should be rewritten to domain.com/abc/index.php/def/ghi
domain.com/xyz/def/ghi => domain.com/xyz/index.php/def/ghi
domain.com/pqr/def/ghi => domain.com/pqr/index.php/def/ghi
What should be the .htaccess file and where it should be placed?
I have .htaccess file in each directory(abc,xyz,pqr) like below, but it is not working. it is showing 404 page not found. Please guide me to handle all these rewrite conditions.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
But this is not working... If this is right .htaccess then please tell me if there is any other server side problem. I am setting up this on CentOs server.
You will probably need a RewriteBase /abc to deal with the subfolders.
I had problem with my directory access, I was needed to update the access for content directory(domain.com) in apache config file(httpd.conf)
I've put my concrete5 installation in the subfolder /www/concrete5. I've tried different entries in my .htaccess file but all modes seem to have some errors.
There is mainly one forum post about it
Domain root - CMS link problem
but it does not seem to work in edit mode. However, this forum post is quite old.
Is there a simple way of accessing a concrete5 installation in a subdirectory as if it were in the root?
Here is a detailed description on how to do this:
http://www.concrete5.org/documentation/how-tos/developers/hide-the-subdirectory-url/
What does your site.php file look like?
I run a lot of cms sites from subdirectories and my htaccess file is pretty standard:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I do the directory specific settings in the site.php file in the config directory.
define('BASE_URL', 'http://domain.com');
define('DIR_REL', '/dirname');