cakePHP hosting not pointing to links - php

I have hosted my new website here http://cvspforcomval.site90.net/ which is a free hosting site. The problem is that I can't see the pictures in my slide, and when I enter to the navigation links I get an error.
I have changed the default webroot/index.php to:
if (!defined('ROOT')) {
define('ROOT', DS.'home'.DS.'a3503999');
}
if (!defined('APP_DIR')) {
define('APP_DIR', 'app');
and my directory goes like this
/root/
public_html/ <---webroot
app/
lib/
I'm just wondering if using the free hosting site affects the error. Or I just missed something out.
<---EDITED Added below--->
In my shared hosting site. I have setup folder in this way
/app
/public_html <---webrooot
/lib
I have the default htaccess in my public_html which is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
My suspicious is that i need to change my .htaccess. I haven't solved it yet

i am getting page not found error which is due to the anchors. You are not using proper ctp links.You have to create the anchors as
$this->Html->link(__'My Page',array('controller'=>'Home','action'=>'name_of_action'));

Related

Deploying Yii2 into shared hosting, Directly to basic template folder

I have read the doc from Yii2 official website to deploy yii2 into share host from this : http://www.yiiframework.com/doc-2.0/guide-tutorial-shared-hosting.html, and about discussion on this : stackoverflow.
So, I decide to use sftp to upload the yii2 folder.
And this is the list of directory in my share host.
access-logs
etc
logs
public_ftp
public_html
ssl
www (this is a link folder to public_html)
You know, because the share host can hold on domains untill 5 domains,
is it possible to upload yii2basic folder into public_html folder ?
So the result like this :
access-logs
etc
logs
public_ftp
public_html
-basic
- bunch of yii folders here
ssl
www (this is a link folder to public_html)
Because now, if I want to access my web, I have to write like this : mydomain.com/basic/public_html/index.php
I need like this :
mydomain.com/index.php
Please guide me.
Yes you can upload it inside the public_html folder but the only problem that I have been facing nowadays with yii2 basic app is the pretty URLs, you can clone or upload entire contents inside the public_html folder, what I did is as follows only the difference is I have a web folder instead of www
directory structure
public_html
assets
commands
config
controller
mail
migrations
models
runtime
tests
vendor
views
web
public_html/.htaccess
<IfModule mod_rewrite.c>
Options +SymLinksIfOwnerMatch
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/.*
RewriteRule ^(.*)$ web/$1 [L]
RewriteCond %{REQUEST_URI} !^/web/
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ web/index.php
</IfModule>
public_html/web/.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
this works but in the URL it shows /web/index.php?r=site/index and as soon as I turn the prettyUrl on in the config file urlManager it would only show default index page and every link I try to open ends up on the home page view although the URL in the address bar is correct and urlManager parses the rules correctly, this is as far as I have gone.
If you don't mind bunch of Yii 2 folders in your root folder just place all basic template folders (except web) and files in the root folder. Then place the content of web folder in the public_html folder.
It should be something like:
access-logs
assets
commands
config
controllers
etc
logs
mail
models
public_ftp
public_html
// here should be the content of web folder of Yii 2 basic app
runtime
ssl
test
views
widgets

Remove public_html from url through htaccess

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.

Removing index.php from Code Igniter

I've done a search for my question but have yet seen one similar to mine.
I have a newly installed CI on my server, for security reason I have shifted the "application" and "system" folder outside of public_html and into a folder called "app". I tried a lot of methods that the forums were using but none seem to help.
Below is my folder structure, would like to know what to type for the .htaccess and where does this .htaccess go to?
/
app (system and application folder for CI resides here)
public_html (index.php - the one which defines ENVIRONMENT, styles, other htmls and my current .htaccess resides here)
My current .htaccess looks like this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]
Please help! Thank you for your time!
EDIT
Currently my url is something like this
xxx.xxx.xxx.xxx/~app/index.php/user/check/id
(it's on a shared hosting but not linked to domain yet and hence the ip address and partition in the url.)
I want to achieve something like
xxx.xxx.xxx.xxx/~app/user/check/id
and it should work when I link up my domain. (e.g. www.mydomain.com/user/check/id)
Alright, I think I've solved the problem.
This has most probably got to do with the 'unique' url that I have. I assume if it is a normal domain name it shouldn't have so much problems.
My url > xxx.xxx.xxx.xxx/~app/index.php/user/check/id
My directory structure remains the same >
/app (application and system directories goes here)
/public_html (index.php and .htaccess goes here)
.htaccess code as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~app/ << NOTE the addition
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
In config.php, set
$config['base_url'] = 'http://xxx.xxx.xxx.xxx/~app/';
$config['index_page'] = '';
That's all!

Main Site Displaying subdirectory in URL

My Main site displays (mypage.com/site) and all following pages include /site as well
How do I achieve (mypage.com) and no subdirectory displaying?
I have tried Removing the /site in the Site Address URL in Wordpress settings.
But it broke my login and disables me from logging in.
what must I do to remove the /site subdirectory folder dislaying on my website?
What do I do in my htaccess file?
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]
</IfModule>
# END WordPress
I supposed that your WordPress installation is under /site folder. If it's true, you can do it:
If you already has changed the URL, on General panel, to http://mypage.com (without /site), you just need to copy the index.php (under site/) to the root folder.
After copy the index.php file, edit it, adding site/ to the path to wp-blog-header.php:
require( dirname( __FILE__ ) . '/site/wp-blog-header.php' );
The detailed steps of this process are on "Using a pre-existing subdirectory install
" at WordPress docs: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
Have you tried to change your document root in Apache?
Something like:
DocumentRoot /path/to/your/site
I don't know if you have access to your hosting, but this would be the best solution as far as I know.
If you can't do it for yourself, you can ask to your hosting provider to do it for you.

Zend Framework with phpBB: URL problem

I am using zend framework with Apache sever on Ubuntu. When I try my site on localhost, I use following url
for example:
http://test.dev/authentication/login
http://test.dev/student/profile
Where 'authentication' refers to AuthenticationController and 'login' refers to loginAction.
'student' refers to StudentController and 'profile' refers to profileAction.
Question: Now I want to use phpBB forum with my site. I had to use the following URL to start phpBB forum with my website.
http://localhost/test/forum/
Where 'test' is my main project(website) directory. I want to use following URL for phpBB forum.
http://test.dev/forum/
How to configure my project to open phpBB forum using above URL? Should I create a controller?
Thanks
I guess you are using apache mod_rewrite with your ZF application.
The simplest solution is to place a new .htaccess file inside the forum/ directory and turn off the rewrite engine
RewriteEngine Off
This works because Apache first look for the .htaccess file in the requested directory, if it does not find one, he looks in the parents folder and so on until it reaches the public directory. When you request /forum/ he finds the .htaccess file there and turns off the RewriteEngine.
After some time I have found my answer. I just placed my 'forum' folder in 'public' folder and it is working for me without changing my .htaccess file.
Here is my settings:
My directory structure is now like this:
/var/www/test/public/index.php
/var/www/test/public/.htaccess
/var/www/test/public/forum
My httpd.conf entry is like this:
<VirtualHost 127.0.0.1>
ServerName test.dev
DocumentRoot 'C:\wamp\www\test\public'
</VirtualHost>
My .htaccess file is like this(it controls both folder and controller/action URLs):
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Last line in above .htaccess file allow me to use my URL without index.php in URL.
After above setting I am able to use following URLs correctly:
http://test.dev/authentication/login
http://test.dev/student/profile
http://test.dev/forum/
In above URLs 'authentication' and 'student' are controllers. 'login' and 'profile' are actions and forum is a directory
Comments are welcome.
Thanks
This will work as well:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php
If you place phpBB in the public folder the webserver will be able to see it and the 2nd two lines of this code will exclude "real files" and "real folders" from the rewrite which is what you want for the forum folder. Obviously the last time, pushes all framework traffic to the index.php file.

Categories