Works only in root folder - yii

My application written with YII framework works only if placed in root folder like: Localhost/
if I place it somewhere like: localhost/test, then it does not work(Links does not work, CSS is not attaching)
Where should I change it? thanks!

You should work around your basePath variable in protected/config/main.php.
In almost all cases it looks like
'basePath' => dirname(__FILE__).'/..'
But if this won't help you i think you should check your web-server config.

Related

How to Serving static files with express if it is inside a subdirectory

I am having trouble with serving a html file which is inside a subdirectory inside public folder.
My directory structure looks like:
public/
HTML/
index.html
index.js
I want to serve the index.html for the root route.
This doesn't work:
app.use('/',express.static(path.join(__dirname,'public')));
According to the docs, this should be enough:
app.use(express.static('public'))
It also gives you such example
http://localhost:3000/images/kitten.jpg
http://localhost:3000/css/style.css
http://localhost:3000/js/app.js
http://localhost:3000/images/bg.png
http://localhost:3000/hello.html
It doesn't go much further other than explaining how you can set up multiple public directories. Anyway, it has worked for me in my projects.
Perhaps you need to state directly app.use(express.static('html')) or app.use(express.static('public/html')). Let me know what works for you.

Vue Nuxt.js - deploy in subfolder

I have a Nuxt.js project and I generate a static app. I need to put it in a subdirectory on ftp, but I can't make it work.
I've set router.base to /subfolder and that works fine for _nuxt, but static files are still using absolute path /img/...
So I've tried to put my static files into assets/img/, but they are not getting loaded from scss when I use ~assets/img/...
I've read many topics, but couldn't find the solution.
Any ideas?
Thank you
I had trouble finding solutions in the documentation as well, but I found out you can use the static folder on a subdomain if the links are changed from:
/image.jpg
to:
~/static/image.jpg
Also if it helps, I believe changing:
~assets/image.jpg
to
~/assets/image.jpg
Might solve your issue?

Play 2.x Static assets not found

I am not sure why my public assets are not being discovered by play. i am using the same code that works in an activator template in a play2 intelliJ project.
the routes
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
and the html
<img src="#routes.Assets.at(s"images/foo.png")" width="64px">
seem to be correct, and the foo.png is in the public/images folder. the inspector highlights images/foo.png in the html with "cannot find" message. they seem to be being compiled, as they also correctly are placed in the target directory. the rest of the app and html is working fine
what is a possible explanation for this?
Try:
#routes.Assets.versioned("images/foo.png")
Honestly, I have no idea why but I know that it works for me.
Interestingly, there was nothing wrong. it seems that between sbt, play, and IntelliJ, there was simply lag in the resource resolution. after about an hour, everything suddenly worked.
this may not be reproducible, and therefore this question might be a candidate for removal

How to get the file upload button to show in the EditMe extension

I'm using the ExtEditMe extension in my project with the following configuration:
$this->widget('ext.editMe.widgets.ExtEditMe',
array(
'model'=>$model,
'attribute'=>'Text',
'ckeConfig'=>array('enableTabKeyTools'=>true,'enterMode'=>2),
'height'=>'500',
'width'=>'100%',
'filebrowserImageBrowseUrl'=>'/protected/extensions/kcfinder/browse.php?type=files',
'filebrowserImageUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserBrowseUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files'
)
);
For some reason the file upload button isn't showing in the tool bar. Is there something else I need to add?
Questions too much for a comment. Could you check the following:
Check the permissions for the assets folder. Need to be writable by your
httpd (example apache:apache or apache:www-data)
EditMe should be inside the protected/extensions/ folder
Change your widget call to:
$this->widget('application.extensions.editme.widgets.ExtEditMe',
(used full path)
Check if kcfinder/config.php says: 'disabled' => false,
Also, there may be a need to put kcfinder in the root of the webapp. See this example with CKeditor.
The following comes from the CKEDITOR docs:
This button will be hidden by default (hidden:true). The filebrowser plugin looks for all elements with the filebrowser attribute and unhides them if appropriate configuration setting is available (filebrowserBrowseUrl/filebrowserUploadUrl).
Which could mean your config settings for the filebrowser plugin are not correct. You should try the following:
KCFinder (your filebrowser plugin) is not a yii extension as far as I know, so move the kcfinder folder to the root folder (or any other folder outside of the protected folder).
Change the paths to the KCFinder files. I recommend using yii's Yii::app()->baseUrl to make sure you're getting the correct paths:
'filebrowserImageBrowseUrl'=>Yii::app()->baseUrl.'/kcfinder/browse.php?type=files',
'filebrowserImageUploadUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files',
'filebrowserBrowseUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files',
'filebrowserUploadUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files'
Hope that helps.
'filebrowserImageBrowseUrl'=>'/protected/extensions/kcfinder/browse.php?type=files',
'filebrowserImageUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserBrowseUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files'
These URLs will be passed to the Javascript initiator of the extension, and they will be requested from there, so you can copy them and try requesting them from the browser to see if they are working (I'm almost sure they won't work).
One way you can work this out, is by creating a controller and includes these PHP files there, then make these URLs refer to the controller you created. Hope it helps.

Laravel wrong public path file upload

I've deployed laravel with this guide.
http://juniorgrossi.com/deploying-laravel-applications-on-a-shared-host/
On my webserver I have a public_html file now containing all my publicly accesable files and a laravel folder containing the rest, so I've split up the default laravel structure for deployment.
On my development server by default the public folder is resting inside the laravel folder instead of being on the same directory level.
The problem I'm getting though is when I use something like this:
// Upload the file
Input::upload('image', 'public/uploads', $filename);
Same with this.
// Upload the file
Input::upload('image', path('public') . 'uploads', $filename);
Instead of trying to use the uploads folder that is inside my public_html folder it tries looking for a public file inside my laravel folder now.
And I get a
Unable to create the "/uploads" directory
Ofcourse on my development server the public folder is still inside the folder so it's logical.
How do I fix this?
You may try this (add a slash after the folder name)
Input::upload('image', path('public') . 'uploads/', $filename);
Maybe try this....just as a test
Input::upload('image', URL::to_asset('uploads/'), $filename);
You can also try
Intervention/image package.
I'm using this and I find it very easy to use. It also has a resize and crop feature.
It's easy as:
Image::make(Input::file('file')->getRealPath())->save('uploads/' . $filename);
Fixed the paths.php to ../public_html
I've done this before but it failed since I accidentaly uploaded a png and my jcrop function wich crops and saves images failed because it currently onlt takes jpg. So that left me thinking my paths.php settings were no good while they actually were.
Thanks for helping out though everybody!
(I feel like a fool.)
In my case, I got the same problem. Then I created it manually, CHMODed the lil' bastard and it worked fine!
Making a long history short (not so long...): just permission!
If you have the permission to Write/Read to the folder, you'll be cool! If you don't, you change the permissions! If you are unable to change it, put the uploaded files where the permissions allows you to access the file.