New Host URL problem- can HTACCESS help?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

New Host URL problem- can HTACCESS help?

Post by simonmlewis »

Hi
We are now using a new host for a web site, but until we are happy it's running we need to test it.
It's using cPanel, and has it in the following format for testing:

http://33.33.33.33/simondomain_/

(obviously this is not genuine).

If I load up http://33.33.33.33/simondomain_/images/logo.png
It works. but if I load up:
http://33.33.33.33/simondomain_/
Which should in theory bring the homepage up, it fails, because.... of the simondomain_ part.
So is there something I can put at the top of the HTACCESS file, temporary, to test this domain works for us? something that includes that part of the URL so the rest of it works.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: New Host URL problem- can HTACCESS help?

Post by Celauran »

How does it fail? 404? 401? Are they any .htaccess rules already in place for the index page?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: New Host URL problem- can HTACCESS help?

Post by simonmlewis »

404 not found, on a blue screen.

HTACCESS is just the general stuff.

Code: Select all

DirectoryIndex index.php index.html index.htm
order allow,deny
allow from all 

Options +FollowSymLinks
Options +Indexes
RewriteEngine On

RewriteRule ^error/?$  /selectpage [QSA]

RewriteRule ^(blog)($|/) - [QSA]

RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2&menu=sub [QSA]
RewriteRule ^categ/page/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=categ&c=$1&cname=$2&menu=sub&pagenum=$3 [QSA]
RewriteRule ^subcateg/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&menu=sub [QSA]
RewriteRule ^subcateg/page/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&menu=sub&pagenum=$5 [QSA]

RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5&h=$6 [QSA]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5 [QSA]

RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [QSA]

RewriteRule ^$ index.php?page=home [QSA]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: New Host URL problem- can HTACCESS help?

Post by Celauran »

The resource that worked was a static asset. Do any pages work? Is it just index.php that's the problem? What if you disable .htaccess?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: New Host URL problem- can HTACCESS help?

Post by simonmlewis »

the problem is, all the images and css files are in /images/* or /source/*, so it's looking for them in the root, and go back beyond the simondomain_ area.

If I run index.php alone, text shows, no formatting, no images.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: New Host URL problem- can HTACCESS help?

Post by Celauran »

That's actually good news. It means everything on the server appears to be configured properly. You'll need to add a RewriteBase to your .htaccess, but your redirects should then work. If your static assets are referencing an absolute path, understandably they're going to fail.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: New Host URL problem- can HTACCESS help?

Post by simonmlewis »

You'll need to add a RewriteBase to your .htaccess,
That is precisely it. There are no absolute references, but I understand the comment.
So what do I need to add to htaccess to make this work?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: New Host URL problem- can HTACCESS help?

Post by Celauran »

[text]RewriteBase /simondomain_/[/text]
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: New Host URL problem- can HTACCESS help?

Post by simonmlewis »

In this order?

DirectoryIndex index.php index.html index.htm
order allow,deny
allow from all

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /simondomain_/
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: New Host URL problem- can HTACCESS help?

Post by Celauran »

Have you tried? Is it working?
Post Reply