how to make htaccess Rewriterule for a file on root? - php

I am using Yii framework, I have a file on the website root named test.php, I want to make a rule that redirects this link "staging.mysite.com/p/test" to this file. what I did:
RewriteRule ^p/test$ test.php [QSA,L]
But I got this error
Internal Server Error
Application runtime path "/var/www/staging.mysite.com/protected/_ws/runtime" is not valid. Please make sure it is a directory writable by the Web server process.

It says your runtime folder is missing.
try create a runtime folder under /var/www/staging.mysite.com/protected/_ws/
and make the permission to be 775
Then try again?

Related

Laravel 5.5 on Godaddy. Producing error 500. internal server Error

I have uploaded my laravel files to a Godaddy shared hosting.
My folder structure is like so
/mediservices
all-other-laravel-files-and-folders
/public_html
public
index.php
The content of the index.php in the public folder in public_html has been edited to point to the medsirvices folder like so -
22. require __DIR__.'/../../mediservices/bootstrap/autoload.php';
34. $app = require_once __DIR__.'/../../mediservices/bootstrap/app.php';
I have added the following to the .htaccess file in the public_html folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^mediservices
RewriteRule ^(.*)$ mediservices/$1 [L]
</IfModule>
I still get a 500 Internal Server Error when i go to the domain.
The full message is
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator at webmaster#medcommhospital.com to
inform them of the time this error occurred, and the actions you performed
just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying
to use an ErrorDocument to handle the request.
Following the comments I can suggest the following. You need to make it clear if you want to serve the site under the domain root or under a folder on a domain.
Keep an eye on your logs, they tell you what the issue is. And make sure it actually is the same error, even a small change in details can give you more information.
Serve site under domain root
If you want to server your site/Laravel project under the domain root so on example.org/ it should be configured like the following.
# Contains all other laravel files
mediservices/
...
public_html/ <webserver root> <laravel public dir>
index.php
.htaccess
Your reference to your bootstrap in index.php should be.
__DIR__ . '/../mediservices/bootstrap/autoload.php'
Your .htaccess file should not need rewrite rules, so you can likely remove that configuration.
Serve site under folder on domain
However if you wish to serve your project from the folder mediservices/ after the domain part in the URL, so like example.org/mediservices/, and redirect users to that folder, you can keep the .htaccess rewrite rules you have, but you'll have to move your Laravel public folder to the following:
# Contains all other laravel files
mediservices/
...
public_html/ <webserver root>
mediservices/ <laravel public dir>
index.php
.htaccess <should stay under the public_html/ folder>
The references you use in index.php should be as you had, which is the following.
__DIR__ . '/../../mediservices/bootstrap/autoload.php'

Webiste url are not routing without index.php

I uploaded my website from my UAT/Test domain to EC2 AWS. Before everything was fine, but now only home page opens.
And if I try to navigate to any other links I can't, it gives following error
The requested URL /page/company was not found on this server.
But when I insert index.php in between it works fine.
Any ideas?
Please enable mod_rewrite module in your server and rewrite index.php in htaccess file.
Please check your file premissions
I believe the issue could be DirectoryIndex which apache (not positive that is what you are using as web server) uses to direct the user to a specific file if a directory is selected in the URL.
This can be set in your apache config if you have access, or in a .htaccess file if you only have access to the your webspace itself.
http://www.htaccess-guide.com/directoryindex-uses/
Basically with DirectoryIndex you can tell apache to automatically use index.php, or index.html, or really whatever file you want to be used when no file in a directory is given in the URL.

How can I upload my local Laravel web project to server?

I work on a website which i made from Laravel and now i need to push it to the server and go live. I'm new to Laravel hosting. Earlier I did coding by pure php and those days i just push the project to server and it works. My server is one.com and this is what i get when i copy my content and try to access the page.
please help me on this manner! thank you
Option 1: Use .htaccess
if it isn't already there, create an .htaccess file in the Laravel root directory. Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder)
Edit the .htaccess file so that it contains the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Laravel has an Entry Point (which is the index.php File). This File lives inside the public folder. To go L-I-V-E with a Laravel Project, you have to set your Document Root to point to the public Directory.
Right now, you can only access your Site by navigating to: http://van.lesthi.com/public/
At the moment of this writing; accessing the URL above throws somewhat of an SQL Error, which you may want to fix first....

Upload laravel 5 project to share hosting

im newbie with laravel. i have problems when uploading my laravel project to my shared hosting.
when i go into my domain.com/laravel/public/ , i cant see anything. they return it with blank page. no error at all. i dont understand.
i try to follow all instructions in internet, but all i got is nothing.
i change index.php inside of public folder.
from this :
require __DIR__.'/../bootstrap/autoload.php';
into :
$app = require_once __DIR__.'/../bootstrap/app.php';
i also modify my .htaccess file into
RewriteEngine On
RewriteCond %{REQUEST_URI} !^awesome-project
RewriteRule ^(.*)$ awesome-project/$1 [L]
but still all i got is blank page.
what can i do to solve this issue?
I'm assuming you're running Apache2? Check your site conf file and make sure the document root is pointed to the public folder.
you should be getting a 404 error if path is incorrect. A white page with a new Laravel installation usually means you need to check the permissions of your storage folders.
From the Laravel 5 documentation:
"Directories within the storage and the bootstrap/cache directories should be writable by your web server"
You should restore your Laravel files to original state, then you must set your host to a laravel/public directory. It will work only if you'll do both steps.
If you have trouble with setting up your web server, you can find an instruction for Apache here:
http://laravel-recipes.com/recipes/25/creating-an-apache-virtualhost
Also, don't forget to restart your web server after doing all the changes.

How to route request to codeigniter project outside document root

I have the following shared hosting file structure using a codeigniter project:
myTLD.com/sites/mysite
mysite contains: application, system , index.php ... ( standard CI2 setup )
myTLD.com/public_html - contains : index.php
I have symlinked myTLD.com/public_html/index.php to myTLD.com/sites/mysite/index.php
Unfortunately I am getting:
Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php
I have set it up this way to avoid placing the actual site in the document root for security purposes . I don't want to change mysite/index.php because I want to keep the entire project in its mysite directory where it can easily be revised etc.
The application and mysite/ folder are set to 755 so I don't think this is a permission problem .
My myTLD.com/public_html/.htaccess folder directs all requests to index.php:
RewriteEngine On
RewriteRule ^(.*)$ index.php
Can someone advise me on an approach to sending requests through to the codeigniter index file without causing this error?
Thank you
You can try following way
1) Remove the symlink
2) Use this in htaccess at myTLD.com/public_html/.htaccess
RewriteEngine on
RewriteRule ^(.*)$ myTLD.com/sites/mysite/index.php?/$1 [L]
Use absolute system path if you are aware of it.

Categories