I have seen many questions like this, which solve in removing public in cases like example.com/public. But in my case i have example.com/cases/public. How to deal with this type of situatations.
Follow this steps to remove the public from url
Copy .htaccess file from /public directory to Laravel/project root folder.
Rename the server.php in the Laravel/project root folder to index.php.
Cheers your will be good now.
Please Note: It is tested for Laravel 4.2, Laravel 5.1, Laravel 5.2, Laravel 5.3.
I think this is the easiest way remove public.
If you want to remove cases/public from url than you can use this
RewriteBase /
RewriteRule ^cases/public http://example.com/ [R=301,L]
Remove direction R=301 in above line to make it internal redirection
Related
I have this project called 'site01'.
It is published as: 'www.example.com/site01'. The pages are like this 'www.example.com/site01/page/1'.
I'm able to route the url to 'www.example.com/site01/1', but can I change the url to 'www.example.com/s/1' through the routes configuration?
Initially I think that you have to use .htaccess way, because the issue is related to the outside of the CakePHP folder.
You can create a new file named .htaccess in the upper folder and write the instruction witch redirect /site01/ to /s/.
sample code for rewrite url:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^site01.*$ /s/ [R=301,L]
I just installed CodeIgniter 3 and it seems that JS,CSS and images should be placed OUTSIDE Application folder. If not, link to those files does not run.
For many reasons I would like to have these kind of files inside application/views folder. I think that I should correctly set .htaccess file, but I would also like to "lower my defenses less possible".
What do you suggest?
All you need to do is in the application folder .htaccss change deny all to allow all and then make sure you auto load url helper and the call your folder from where ever you want.
Update you could try this code in application/.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|assets/css|assets/js|assets/ficheros|assets/img|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
rename assets folder to what you want if using xampp/wampp etc do not for get to stop and then restart it. Of course when paste code do not for get to remove the deny all.
Its simple, just delete the contens inside the .htaccess file. It worked for me.
I'm having a problem with denying access to the root directory of my Laravel Site...
I have my project in xampp/htdocs/laravel
Of course Laravel routes the /public directory...
But how can I deny access to the directory xampp/htdocs/laravel ...?
How can I prevent the directory listing?
The only way I've found is putting an index.php with a header("location: /laravel/public")
But I dont know if it's the best way... should I use .htaccess? How?
I've tried a few but it results in major errors across the server.
You need to open your httpd.conf file (xampp/apache/conf/httpd.conf) and change the "DocumentRoot" value to include the path to your public folder:
DocumentRoot "C:/xampp/htdocs/laravel/public"
Or just add a .htaccess with :
RewriteEngine On
RewriteRule ^ public [L]
I do not want to use mod_rewrite on cakephp and I want to use cakePHP's pretty URLs. So I have removed all the .htaccess files
/.htaccess
/app/.htaccess
/app/webroot/.htaccess
and uncommentted this line on core.php
Configure::write('App.baseUrl', env('SCRIPT_NAME'));
Noe the problem is...if I am putting controller and action in URL it is showing a 404 not found error.
http://www.mydomain.com/controller/action - showing not found
Can anyone help me out this.
Try either:
http://www.mydomain.com/index.php/controller/action
http://www.mydomain.com/index.php?controller/action
I'm trying to have everything in this folder on my website - http://www.mywebsite.com/media/images/* redirect to another website with the same structure i.e. http://www.theotherwebsite.com/XXX/media/images/* using .htaccess
Even simpler, it can be accomplished by Redirect alone, no need to use Rewrite.
Redirect permanent /media/images http://foobar.com/new/location
Okay... managed to figure this one out...
RewriteRule ^media/images/(.*)$ http://www.theotherwbsite.com/XXX/media/images/$1 [L]