I have followed answer described in this question. I have moved Application files and folder to one level up as suggested.
public_html/basic/web,config etc.. to public_html/web,config etc..
Removed index.php from url by modifying these configuration:
config/web.php
'urlManager' =>[
'enablePrettyUrl' => true,
'showScriptName' => false,
],
htaccess file in web folder
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
So now my url is example.com/web/controller/action
How can I hide web from the url above? I don't have access to the apache configuration file.
My answer still stands :).
You are on the right track, move everything 1 directory lower. Right now you copied the entire yii2 application in public_html, you should move it 1 directory down. Then copy everything you have in web in public_html. By doing this all your scripts are not exposed to the web, only 1 index.php will be exposed and that is the proper way to have it set up.
Also this is the main tutorial for yii that tells you how to do it https://github.com/yiisoft/yii2/blob/master/docs/guide/tutorial-shared-hosting.md
Do not be afraid of doing this, take the blue pill (or is it red) :).
you can try to add in config\web
$baseUrl = str_replace('/web', '', (new Request)->getBaseUrl());
$config = [
'defaultRoute' => $baseUrl,
'components' => [
'request' => [
'baseUrl' => $baseUrl,
]
],
'urlManager' => [
'baseUrl' => $baseUrl,
]
Related
I'm trying to develop a shopping system with codeigniter.
I developing the back-end & front-end of my shopping system.
But my problem is I want to use this code for many stores.
For example my main address is shop.com.
I want people can have their own shop in my system with their own subfolder like this: shop.com/shop1 | shop.com/shop2 & ...
I want the users subfolder placed out of application folder.
My directory list like this:
shop.com
-application
--cache
--config
--controllers
--core
--helpers
--...(other application contents)
-assets
-attachments
-system
-shop1
-shop2
& ...
I making all shop parts and every thing is ok when i call shop.com.
Now I want to making shop1 with specific subfolder and database.
I can making separate database for each shop and connect the code to his own database. after this I call shop.com/shop1 and the main page load like a charm.
But when I call shop controllers ( example: shop.com/shop1/checkout ) I get 404 error.
And at the end I noticed two point:
1- I use the original codeigniter root index.php code as my shop1/index.php
2- I change the $system_path to ../system and $application_folder to ../application
It seems codeigniter unable to locate the controllers properly.
What can I do to solving this problem?
You mean HMVC?
Download files and copy C.i.3.0 forder in application : https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads
Create and coppy paste in .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
3.Create folder name 'modules' in application/
4.Create folder name 'folder' in application/modules
4.Create folder name 'controllers, models, views' in application/modules/folder
5.Create file name 'file name same folder' in application/modules/folder/controllers
for error
paste this in MX/Loder.php
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
I am having a small issue creating a dynamic sitemap.xml for the site.
My routing file:
Route::get('sitemap.xml', [
'uses' => 'PageController#sitemapXml',
'as' => 'user.page.sitemapxml'
]);
My controller:
public function sitemapXml(){
....
$content .= '</urlset>';
return response($content, 200)->header('Content-Type', 'text/xml');
}
My issue:
To access get the correct response i have to use the following route:
www.mysite.com/index.php/sitemap.xml
However, if i do www.mysite.com/sitemap.xml, i get a 404.
If i manually add the sitemap.xml file in my public folder, i can access the file i just added, but not the dynamic one created in my controller.
My research:
Its probably a problem with the server and not laravel itself. Apparently, .xml extension are not processed through the normal routing.
It suggests adding:
location = /sitemap.xml {
try_files $uri $uri/ /index.php?$query_string;
access_log off;
log_not_found off;
}
that did not work.
I also tried the changing my .htaccess to this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
as specified in the docs
My question:
Is their anything I can do laravel-wise to handle .xml requests?
Also, if you could guide me towards anything that might help me understand this process better, its very welcomed.
Thank you in advance for taking the time to help
UPDATE:
if instead of using my localhost, i use "php artisan serve", things work correctly without any issue.
I found the answer on this link:
https://laravel.io/forum/09-15-2015-removing-indexphp-from-url-laravel-5116
I changed my .conf file and voila.
Hope this helps you
Just to clarify: Nothing wrong with Laravel. More server specific.
I am reading Laravel4 quick start tutorial
Laravel4 quick start
I have installed laravel4 on Wamp server in Windows . I was able to access home page which says "you have arrived".
Later in ther router.php I have added only one router as per quick start guide, but for some I am getting this error.
Error:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Router.php
Route::get('/', function()
{
return View::make('hello');
});
Route::get('/users', function() //this one i hav added
{
die;
return 'Users!';
});
config.php
'debug' => true,
'url' => 'http://localhost:99',
'timezone' => 'UTC',
'locale' => 'en',
Do not prefix the route with a slash. Use users rather than /users.
I had exactly the same problem today and it took a while to resolve it, but here's how I did it. In this example I created a WAMP Apache Alias 'lava', so http://localhost/lava/ took me to the "You have arrived" page successfully. However even trying a really basic route of:
Route::get('test', function()
{
return "hello?!";
});
Would give me the NotFoundHttpException errors the same as you. To get routing working I did this:
Ensure mod_rewrite is enabled (WAMP does it by default, but double-check)
Ensure open_ssl is enabled (easy to do via the WAMP tray icon)
Edit app/config/app.php and set the url to match your alias, so in my case:
'url' => 'http://localhost/lava/',
Edit public\.htaccess - you can use the one the QuickStart recommends, but you need to change it in 2 places:
```
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /lava/
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /lava/$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
```
In the above I've added the RewriteBase line which matches the alias, and also added the alias in the RewriteRule regexp.
The above for me works fine (Windows 7, WAMP) although the .htaccess file is no use when deployed to a live server that doesn't use the same alias.
Trying going to index.php/users. If this loads then you need to setup url rewriting in the htaccess file.
Why i can't get an image to work. I'm trying this:
background-image: url(jBootstrap/images/ui-icons_222222_256x240.png);
and it doesn't work. When i'm trying to access it trought URL i get an error:
Asset [stylesheets/jBootstrap/images/ui-icons_222222_256x240.png] was unable to be processed.
Can't get any images, tried in many variations of directories and still doesn't work. When i'm doing this on plain html-css it works perfectly, but not in laravel. What am I doing wrong ?
btw, i'm using Basset if it helps.
EDIT 1
Also including the additional information about a partial structure of my public folder and html link generated by basset:
public/
stylesheets/
jBootstrap/
images/
ui-icons_222222_256x240.png
main.css it contains the background-image...
when including the css file, in source code i see:
<link rel="stylesheet" type="text/css" href="http://localhost/Job/worker/myapp/public/7n3C5wypAmTi8VT8/application/stylesheets/main.css" />
Edit 2
Adding my public/.htaccess file:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Edit 3
Tried another way:
public/stylesheets/main.css
public/stylesheets/abc.jpg
in main.css I have code: body { background-image: url('abc.jpg') } and i'm getting nothing ...
Please help, struggling 2 days now ...
Found the problem... It was Basset package, it wat required to put $collection->apply('UriRewriteFilter'); into configurations.
I would naturally assume that one (or both) things are incorrect here:
Your .htaccess file is not checking for existing files when rewriting. Check to see if RewriteCond {%REQUEST_FILENAME} !-f exists in that file.
You are not requesting your background image from the root, i.e. absolutely. Try requesting the resource using a leading slash. For example, instead of calling foo.png, try calling /foo.png.
Try using setArguments('../') on your collection
'collections' => array(
'application' => function($collection) {
$collection->add('../vendor/twitter/bootstrap/less/bootstrap.less')->apply('Less');
$directory = $collection->directory('assets/stylesheets', function($collection) {
$collection->add('main.css');
})->apply('UriRewriteFilter')->setArguments('../')->apply('CssMin');
}
),
This did the trick for me.
I'm developing a website using Kohana 3 (1rst time I use a framework). Locally, everything works perfectly. At the moment, I have a default template controller, a multi-language support and my 'index.php' is correctly removed. So before going further, I tested if it worked on my server and I got an endless loop.
I followed the tutorial from the unofficial wiki for the multi-language implementation: http://www.kerkness.ca/wiki/doku.php?id=example_of_a_multi-language_website
A redirection to the default language occurs if the language is not specified in the uri so I figured the problem might have come from there even though it worked locally, so I removed it to see what happens without the redirection. Now, I can see my home page, but whatever the uri is in the web browser, the home page will always be called. I inserted the following line in my home view to check what the uri was:
request::instance()->uri() and effectively, the uri is always: /en/home/
I put the index.php back (in the bootstrap) and everything worked fine again, even with the redirection to the default language.
My first guess was that the uri isn't rewritten correctly, so I tried to change the .htaccess but no success...
Here's my .htaccess:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /dev/
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(application|modules|system)/ - [F,L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
(btw I also tried the other RewriteRule in the unofficial wiki, doesn't work either)
Additional info:
Host: WebHostingPad
Apache: v2.2.11
PHP: 5.2.9
Rewrite_Module is activated
Thank you, I would really appreciate your help because I've been trying to fix this for days now and it's really starting to annoy me ;)
The only thing you have to change in order to get rid of index.php in URL is to set the 'index_file' param in Kohana::init ( bootstrap.php ) to FALSE ( everything else can cause an error ).
So the Kohana::init looks like this;
Kohana::init(array(
'base_url' => '/',
'index_file' => FALSE,
));
If it worked with the original .htaccess, there's no need to change it at all.
The problem came from $_SERVER['PATH_INFO'] which returned no value...
This issue can be solved by adding the following line to the php.ini:
cgi.fix_pathinfo=0