Redirect directory to subdomain cpanel - php

Alright I have already contacted BlueHost Support and they couldn't figure out how to fix this issue. I've also tried to use cpanels 301 permanent redirect but that doesn't work so I decided to give it a whirl on here.
I host with BlueHost.com if you haven't caught that by now. The file structure is as follows:
public_html/
directory1/subdomaindirectory
directory2
directory3
I have my main website in my root (public_html). Then I have to create new directories and assign the url to that directory. So essentially if you typed in www.maindomain.com/directory1 it would show the website in the directory. I would like to modify the .htaccess to redirect that to it's original domain so www.maindomain.com/directory1 would go to www.directory1.com
The same for subdomains. I created subdomain.directory1.com and pointed it to public_html/directory1/subdomaindirectory and if you go to www.directory1.com/subdomain it pulls up the site.
I realize theoretically it's the same thing but it bugs me that you are able to pull up a website like that.
Is there anyway to modify the .htaccess to fix this issue?

In.htaccess you could do it like this
RewriteEngine On
RewriteBase /gorbox
RewriteCond %{HTTP_HOST} ^www.gorbox.com$ [NC]
RewriteRule ^support$ http://support.gorbox.com [L,R=301]
Put this in the .htaccess file that resides within the root folder of www.gorbox.com

Related

Stop Wordpress on Subdomain

I have a website (http://alvarezpatrick.com) that uses wordpress. I have set up a subdomain (portfolio.alvarezpatrick.com) which I want to use to show example projects, etc. and which I would like not to be part of wordpress. However, if you go to http://portfolio.alvarezpatrick.com it seems to redirect you to http://alvarezpatrick.com, and if you go to http://alvarezpatrick.com/portfolio_html/index.php it seems to say it isn't found.
From looking around I've seen that it should work if I do the following, but unfortunately it does not:
Edit the .htaccess in the main public folder by adding:
RewriteCond %{http_host} ^(www\.)?alvarezpatrick\.com$ [nc]
Create a .htaccess in the portfolio.alvarezpatrick.com domain root folder "portfolio_html" with the following single line of code: RewriteEngine Off
Your main website is on public_html. To avoid using the wordpress on your sub-domain you can point the sub-domain outside the public_html.
For example:
/portfolio/ --- portfolio.example.com
/public_html/ --- example.com

uploading yii2 basic on shared hosting but not working

I am installing Yii2 on a shared hosting environment,Apache, (Godaddy),
here is what I did as per the docs:
Renamed web folder to www
copied all the folders, now the directory structure looks like this:
public_html\
assets
commands
config
controllers
model
modules
views
www\index.php
.htaccess (this is both in public_html and www)
but when I access my domain, I get the following error:
You don't have permission to access / on this server. Additionally, a
404 Not Found error was encountered while trying to use an
ErrorDocument to handle the request.
Here are the contents of my .htaccess which I have copied in both public_html and www.
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
is the htaccess creating problem? Is index.php not being run from the right folder? What else should I look for? any help is much appreciated.
Update:
The actual problem with the above error was that It was a Permissions issue.
Set the permissions from 644 to 755, and now the system is accessible.
BUT
the to access index.php I still need to navigate to it manually by typing in the url : www.example.com/www/index.php
UPDATE
As I don't have prettyurl's enabled, just to make it work, I deleted all the contents of the .htaccess, then I copied the contents of basic folder in the home folder (for future visitors it should be like home/your_user _name
CAVEAT EMPTOR
I know almost nothing about .htaccess. Also my this project is just for learning, this solution may not be useful in production settings.
Question is still open for expert advice on best practices in such scenario.
You need to move your domain pointer to www instead of htdocs, its probably somewhere under domain -> root folder. Your .htaccess looks fine.

htaccess redirect to subfolders resources

I have a problem:
I have to modify an application written in Zend 1 that was deployed to the domain root. now to test it the customer gave me a root subfolder called [domain]/social
When I run it, I have a lot of problem because all paths are like "/resource", but in this case the fiddler show me that the request look for [domain]/resource ad not for [domain]/social/resource.
It happens with script sources, ajax urls, hrefs...all!
Is there a way to fix the problem?
I am not quite familiar with Zend, but is there a main config file that sets the application root folder? (Like joomla) You can modify that if it exists.
Other option would be to preg_match or str_replace all instances of the domain name in the code ( like when moving a Worpress site) but you should definately do that with a sample content not couple hundred pages).
And here is a htaccess snippet as well:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/social/$1 [R=301,L]
Be sure to put the htaccess under the development folder not under the root, oterwise you're facing issues.
I suggest cheking for a config file first. Hope one of this helps!

.htaccess WP-admin url twice

I am unable to access my WordPress site URL, it redirects like
http://www.mydomain.net/wp-login.php?redirect_to=http%3A%2F%2Fmydomain.net%2Fmydomain.net%2Fwp-admin%2F&reauth=1
but it shoud redirect to
http://www.mydomain.net/wp-login.php?redirect_to=http%3A%2F%2Fmydomain.net%2Fwp-admin%2F&reauth=1
I believe the problem is with .htaccess file as I am rewriting the path of folder like
public_html/mydomain.net
instead of public_html as this domain is primary domain of cPanel but to avoid confusing, I created a directory and rewriting path using .htaccess.
There is nothing wrong with WordPress. In settings>general both the URLs set to mydomain.net
.htaccess code is Placed in Public_HTML
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.net$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.net$
RewriteCond %{REQUEST_URI} !mydomain.net/
RewriteRule (.*) /mydomain.net/$1 [L]
I had a similar problem after changing the root directory of my blog (before migration) and trying to coming back... Changing the data in my DB was not working for me.
I still did not figure out why but I had a "page not found" when I tried to access categories, tags,... and even on the home page. Links to articles worked correcly and the administration page was not accessible (wp-admin rewritten twice in the url).
These actions solved my problem:
Edit the wp-config.php file.
After the "define" statements (just before the comment line that says "That's all, stop editing!"), insert a new line, and type:
define('RELOCATE',true);
Save your wp-config.php file.
Open a web browser and manually point it to wp-login.php on the new server.
I had to change the value of the root directory in the administration page (after these actions gave me back the access to it).
Check http://codex.wordpress.org/Changing_The_Site_URL#Relocate_method for more info.

Inherited PHP site not finding assets

I've inherited a PHP site from another developer and can't quite figure out what's going wrong. I'm suspecting some kind of rewrite rule somewhere but Im not sure where to look (or what specifically to look for...)
I've installed MAMP and it is working fine. I've got a couple sites running in the MAMP directory with no problems.
When I drop this site in and try to run the pages, I get pages with no CSS, JavaSCript or images. When I 'right-click' an image and open it in a new tab the image can't be found because the browser tries to go up one level in the directory to the MAMP directory in stead of looking in the site root directory.
Same thing on links to other pages, they all try to go up to the MAMP htdocs directory.
For example in htdocs I have the root folder of my site with the index page: 'htdocs/mysite.com/index.php'
On the page is a link to another page <li class="nav_company">Company
Clicking on 'Company' causes the browser to go up to the htdocs folder and look for the '/company/index.php', which of course doesn't exist.
Where do I go looking for the culprit on this? Is there a term or something I can search the site files for? I'm using dreamweaver and cold utilize the find and replace tool if I just knew what to go looking for...
Edit Here's the (sanitized) .htaccess file in the root folder of the site
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sitename\.com
RewriteRule (.*) http://www.sitename.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.sitename.com/$1 [R=301,L]
Redirect 301 /products/ http://www.sitename.com/plastic-handles/
Redirect 301 /plastic/index.html http://www.sitename.com/plastic/plastic.html
Redirect 301 /applicator/index.html http://www.sitename.com/applicator/applicators.html
Redirect 301 /company/index.html http://www.sitename.com/company/about-us.html
Redirect 301 /contact/index.html http://www.sitename.com/contact/contact-us.html
Redirect 301 /news/index.html http://www.sitename.com/news/news.html
Redirect 301 /trade/index.html http://www.sitename.com/trade/tradeshows.html
Thanks in advance.
It would seem that your assets and links are all pointing to the root so /contact/index.php will look at http://localhost/contact/index.php instead of http://localhost/mysite.com/contact/index.php
Look into setting up a virtual host to point to the new sites directory.
Otherwise it would be a case of changing all the links and assets to the full URL e.g. http://localhost/mysite.com/contact/index.php
Hope this helps
Edit: here is a guide to setting up a virtual host http://sawmac.com/mamp/virtual/
Edit 2: in response to your edit, .htaccess isn't going to make a difference as when you click a link or the server looks for an asset it's going to be looking in htdocs/. It will go no further and therefore will not reach your .htaccess.

Categories