I'm using cakephp 3.0 and I'm facing a problem. I upload my site on server on root level, where I place some demos which I can use for other purpose. Now issue is that when I access my site with domain name then it is working fine. But if I give any folder name which is placed on root level which is not the part of my site and is indiviual part of site. Then it is not accessible.
Below is my folder structure of root level
There a single folder named gallery is a demo. How can I allow this folder to access like this http://hostname.com/gallery or any other new folder.
My .htaccess file code is:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
Please help me on this issue which is more appreciable.
Thanks in advance.
Just move your "gallery" folder under "webroot".
Try this it's worked for me.
create the .htaccess file in "gallary" folder with following content.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
</IfModule>
and try with URL http://server_name.com/gallary
You have access for that folder and files.
Thanks.
Related
i have try a few solution from any source, but still cannot remove index.php if my project in other folder like : http://localhost/project/my_codeigniter, all .htaaccess and configuration work fine if my project in http://localhost/my_codeigniter.
hope you can help me, thanks!
You can create a .htaccess file on your project root folder. File content like this;
RewriteEngine on
RewriteCond $1 !^(index\.php|assets)
RewriteRule ^(.*)$ /your-project/index.php/$1 [L]
I have a legacy project on a server where the actual framework is in a folder above the public_html folder. So the directory structure is like this:
domainname.com
app/
framework/
public_html/
index.php
Now I want to place this on our own server. This is an application created by the hosting company. The root folder is default. So now my directory structure is like this:
default/
app/
framework/
public_html/
index.php
Now he's pointing to the default folder instead of the public_html folder. That's the only difference with the old version. So I've added a .htaccess file to the root folder default. The content of this file is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /public_html/$1 [QSA,L]
</IfModule>
In my public_html folder I have a .htaccess file like this:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule . index.php [QSA,NS]
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule . /index.php [L,QSA,NS]
So when I go to my website it works. But when I click on a link I get: http://domainname.com/public_html/theclickedpage/.
But I don't want the public_html in my url. How can I fix this?
You may want to search for a way to make a virtual host. I know some of my webhost let me configure the vhost through my admin page. It will let your server consider the url without including the specified folder, but back in the stage it performs needed redirection.
You applied correct rule ,
but the problem is link for the solution of this issue you have to
remove public_html from
your all links and it will automatically redirect to your required
path without public_html.
I have created a small web application in PHP and I am struggling with the .htaccess file
I have this file structure:
/Main Project
//App
// controllers, models, core, views
//Public
// css
What i did till now is to redirect from localhost directly to the /public folder like this:
RewriteEngine On
RewriteRule ^$ /public/ [L]
How I can do it to work the same as localhost/public/controller/action/params but just localhost/controller/action/param1/param2 ?
Thank you in advance for trying to help me!
So after trying it this days i found a solution for me and i can redirect to the public folder and also pass the controllers, methods and parameters. If somebody will have the same example, here is what works for me:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
This is basically the Laravel example :)
I created my application in XAMPP and it worked fine, now when I have shifted it on my website's subdomain. When I try to open the login page of my application it gives error Unable to locate the model you have specified
Directory Structure on subdomain:
public_html/
Subdomain/
Codeigniter/
application/
models/
views/
controllers/
Login Page of my Codeigniter application is:
On local host
http://localhost/INvoice/index.php/admin/Login_Controller/
On website
http://subdomain.example.com/index.php/admin/Login_Controller/
In xampp for codeigniter I use this htaccess with windows 7 & 8.
Options +FollowSymLinks
Options -Indexes
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
Order deny,allow
Deny from all
</FilesMatch>
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I use sub domains on live and that htaccess works fine so long it is in main directory of the subfolder and parent directory. I think because you have deny all which is causing you issue.
Main Directory
Sub Dir Demo
I figured out the problem. Basically I have problems in my file naming convention for models. I have been using Capital letters in File Name i.e. Login_Model.php and when I changed it to login_model.php it is fixed.
Just to you know, My .htaccess is still empty but I have no problem in my URLs.
I've searched through Web to solve my problem but non of the solutions works for me there, so after couple of hours of struggling with Routing module I've decided to ask you for a helping hand.
Problem
I am unable to access Laravel application from outside /public directory. I need to type localhost\projects\laravel\public in my browser but what I want is to use the URL withour /public. The main reason is because I use shared hosting and have no access to apache configuration file so I'm unable to create vhost.
Background
I've installed manually Laravel framework under the: **c:\xampp\htdocs\projects\laravel** and used composer to do the rest for me.
The routing has been set to: Route::get('/', 'HomeController#showWelcome');
In my project root directory **c:\xampp\htdocs\projects\laravel** I've put a .htacces file with the following content:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projects/laravel/
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
In my Application Root dir c:\xampp\htdocs\projects\laravel\public I have .htaccess with the following code in it:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
When I type: localhost\projects\laravel\ I've got NotFoundHttpException
When I type: localhost\projects\laravel\public I've got welcome page
Any help would be appreciate, Thanks.
Finally I've got this thing working. There are two solutions that can be made.
One requires to move all -public content level-up
Second requires slightly changes in your shared hosting directory root structure - if allowed
Solution #1
The first that works for me that I didn't want to implement has been posted by #Wasim in this thread: Laravel 4 removing public from URL The solution is not save as the content core structure is in the same directory as application itself. This could cause some problems in future implementation.
You need to move all the content from public/ folder one level-up into project ROOT directory then replace internal paths in index.php file for correct onece. For security reasons this .htaccess file needs to be put into project ROOT directory
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Modified Laravel structure described above can be uploaded to your shared web hosting and the application should runs withour /public in yor http address.
Solution 2 (with no access to http.conf file on your shared hosting)
This solution does not requires form you to move the content of the /public folder one level-up but requires form you to have read and write access to ../ROOT directory in your shared hosting (../ROOT directory mostly contains public_html, public_ftp and other folders).
You need to move Laravel scructure into ../ROOT directory as follows:
app/
bootstrap/
vendors/
public_html/
public_ftp/
(...)
Files form /public folder goes to public_html
public_html/index.php
public_hmtl/.htaccess
public_html/packages/
(...)
Then modification for /bootstrap/paths.php is required for line with 'public' key:
'public' => DIR.'/../public' to 'public' => DIR.'/../public_html'
If someone has similar issue and this solution does not work please let me know, thanks.
If you want without public on uri, using composer from your laravel root. Use command php artisan serve and browse localhost:8000 from your browser. It will bring you to homepage.
Where did you get this line from?
RewriteRule ^(.*)$ public/$1 [L]
It's not part of Laravel. Try removing it or the whole .htaccess file in your Laravel root.