Configuring CakePHP .htaccess for Cpanel ~temp/ URL - url-rewriting

I'm trying to set up CakePHP 2.x in Cpanel (Hostmonster) while the domain of the site is still pointing to the older server. In order to pull up the site without the domain (for demo), I have to use http://[hosting-IP-address]/~mysite.
This is my default .htaccess file located in the root (the one before app/ folder):
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
If I leave it as it is, I get 404 error. When I remove the .htaccess file or leave it blank, the site content loads, but without CSS. The site files are located in /home2/mysite/public_html/ folder. I tried adding RewriteBase with different combinations (~mysite, mysite, mysite/public_html), but no avail.
I have tried with rewrite base setting then i get 500 internal server error. Please suggest

Instead of changing your site .htaccess code. I will suggest you update your local pc host file to point your site to new server, so that you can check your all URL.
Open your hosts file which is located at : c:\Windows\System32\Drivers\etc\hosts and add the following code with your new hosting IP address
hosting-IP-address www.domain.com
hosting-IP-address domain.com

Related

Public url issue in aws in laravel

I have hosted my site on aws through ftp,
now when i access this
url : http://X.XXX.XXX.X/projectfoldername/
i can access the page after i use
http://X.XXX.XXX.X/projectfoldername/public
but i want to remove public changed htaccess file also but when i upload it on cpanel it is working.
.htaccess file :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]
</IfModule>
Any help is highly appreciated
Nearly all Linux OS's have a .conf file that you can use to tell it which folder is the public folder. This needs to be updated for Laravel to work.
From here (https://bobcares.com/blog/cpanel-change-root-directory/), for cPanel:
4. Updating cPanel files
cPanel/WHM does not have an option to change the document root of the main domain via any interface. By default it is the public_html folder in the user home directory.
In certain rare scenarios, we have customers who want their document root to be changed to another folder than public_html.
This has to be done from the backend by updating the cPanel user account file at /var/cpanel/userdata/username/domainname .
The following parameters are updated with the desired directories.
documentroot: /home/steinknu/public_html
scriptalias:
-
path: /home/steinknu/public_html/cgi-bin/
For sites with SSL installed, the configuration file for SSL is also updated accordingly.
This file is available at the location /var/cpanel/userdata/username/domain_SSL .
After making the changes, the user data cache is updated and Apache configuration file is rebuilt to reflect the changes in the corresponding files.
The Apache and PHP-FPM services are restarted and we verify the relevant configuration files to ensure that they are all updated properly.

Magento 404 front end on Multi Site after moving server

We have recently moved a Magento multi site environment to a new dedicated server, however all the sites apart from the admin URL site (not used apart from admin are) are reporting Magento style 404 pages on the front end.
We have ensured mod_rewrite is turned on, checked the database and manually amended the URLs in PHPMyAdmin to assign some temporary test URLs. The URL assigned to the admin area works fine, and the rest resolve to the server, however every front end is still 404. We have tried adding in index.php to the URL, no change. Checked all file and folder permissions, all OK. Cleared all cache manually and reindexed from command line. No change.
We have checked HTACCESS is correct which it looks to be. We have even taken another backup of the database and full site and restored to another server with the same issues.
We have also tried disabling SEO urls/URL Rewrites without change too.
Error logs dont say a lot either which isnt helpful.
Really struggling with this now so any help or pointers greatly appreciated. Thanks
First Solution:
Replace current .htaccess file with the default .htaccess file from Magento.
Second Solution:
#fastcgi_param MAGE_RUN_CODE default;
If doesn't work, try following solution:
Third Solution:
Is this installed on an Apache webserver? If not, the .htaccess functions will need to be translated to your flavor of web server software.
Has DSO module for mod_rewrite been installed in Apache and been enabled to load?
Is AllowOverrides enabled for the virtual server so Options +FollowSymLinks will function? You may have to check with your hosting service provider and have it enabled.
Is Magento's .htaccess file available in the doc root folder?
Has the rewrite engine been turned on in the .htaccess file?
Has the proper RewriteBase been assigned in the .htaccess file?
General entries in Magento's .htaccess that must function so rewrites will function to eliminate the need for index.php to appear in the URL.
<IfModule mod_rewrite.c>
############################################
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
############################################
## you can put here your magento root folder
## path relative to web root
#RewriteBase /magento/
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
Third solution from Fiasco Labs

laravel 4 using a subdomain

I am running laravel on a subdomain i.e. subdomain.mysite.com
I have setup my structure like this:
username
-public_html
--subdomain
---public
Basically, when I created my subdomain the path I set was subname/public so the subdomain points to the public folder. I have uploaded laravel to subname so when someone goes to the subdomain url it looks at the public folder and it shows the laravel You have arrived page.
Now when I browse to mysite.com/subname it gives me a forbidden page and when I browse to mysite.com/subname/public it shows the laravel you have arrive logo.
Is it safe to set-up laravel on a subdomain this way or am I exposing the app / model / controller folders etc?
Is this just very bad and should i move the laravel core files above public_html?
I hope this makes sense
Thanks
With proper Apache configuration (or any other server you use) and .htaccess ( in case of Apache) you can restrict the access to your core directories irrespective of where your files are located.
I do not know about your server configuration and which folders you have access to, but in case you have access to other directories, you can set up laravel in somewhere else other than under public_html and set up public directory to be visible, just like you did when setting up it as a sub-domain.
If you want to setup as a sub-folder under mysite.com you can keep the Laravel installation somewhere else, and provide symbolic link under public_html like this
ln -s /path/to/laravel/public /username/public_html/subdomain
In such case you need to add following line to .htaccess file.
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /subdomain # Add this line
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Hope this helps.

url rewriting in php on xampp server

I've trying out url rewriting with a php script on my xampp server. First i created a .htaccess on the same folder as the script and then wrote the following lines in it
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^direct/?$ direct_name_here.php [NC,L]
to rewrite localhost/map/direct_here123.php to localhost/map/direct/
But the browser displays the url localhost/map/direct_here123.php instead of localhost/map/direct/
How can i fix it?
regards
ED

.htacces file and MAMP

I have installed MAMP on my laptop and moved my web project (developed using CodeIgniter) under MAMP's webroot.
I use an .htaccess file to hide my index.php file within my urls and everything is working fine...almost, everything.
I'm able to surf my site locally as in my remote server but some folders/files are not recognized. Looks like they are missing or the path is not matching the physical location on my laptop.
Basically I have configuration like below:
MAMP
htdocs
myFolderSite
.htaccess
site
myApplicationFolder
.htaccess
config
controllers
views
.....
...
myPublicFolder
css
images
.....
...
Surfing my site locally css and images are not visible. All the required files are present under the proper folders within myPublicFolder.
The .htaccess file I'm using in myFolderSite appears as below
RewriteEngine On
RewriteBase /myFolderSite/
RewriteCond $1 !^(index\.php|images|upload|users|thumb|fckeditor|public|css|js|robots\.txt|sitemap2\.xml)
RewriteRule . index.php [L]
Am I missing something?
Thanks in advance
The CodeIgniter wiki has a good article on Mod Rewrite that is worth looking at. Specifically, these two lines will stop actual files and directories being redirected.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
I've used this across a few different servers and Macs, without too many problems, so hopefully it helps.

Resources