14 Replies - 816 Views - Last Post: 23 July 2011 - 09:38 AM

#1 56KBs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 17-January 11

htaccess, nice urls and header location issues

Posted 23 July 2011 - 05:02 AM

Hey all,

I am in need of some help, I found a nice little snippet for htaccess which will make /index.php?page=login become /login but it seems after I used this code I had to edit all my header locations from index.php?page=login into login for this to work. Else it will just show the url as index.php?page=login

htaccess code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]


After editing all my header locations into just text such as login everything was fine on my XAMPP server, but when I put it all on my web host it seems that this htaccess thing has stopped working, I keep getting "The requested URL /sites/infusion/projects/catalogue/index.php was not found on this server."

Is this due to the fact my domain is hosted within a subdomain, which is in subdirectories from my / directory?

Is there any way I can fix this issue and make it work with nice looking url's?

Is This A Good Question/Topic? 0
  • +

Replies To: htaccess, nice urls and header location issues

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 05:05 AM

Not a PHP question moved to Web Development
Was This Post Helpful? 0
  • +
  • -

#3 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 05:08 AM

Is your server definitely Apache, and are you definitely allowed to use .htaccess files? I mean is the .htaccess working at all (put an error in it to find out)?
Was This Post Helpful? 0
  • +
  • -

#4 56KBs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 17-January 11

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 05:31 AM

Sorry about putting it in the wrong section.

And yeah, if I just type error into the file it comes up with a server error.

It's as if it is trying to get the file from the wrong directory.

Having said all this, I am in the process of waiting for my sub-domain to be setup, so perhaps it will work using the subdomain
Was This Post Helpful? 0
  • +
  • -

#5 56KBs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 17-January 11

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 07:31 AM

Okay, even with the sub-domain working it still does the same.

It tries to include /sites/infusion/projects/catalogue/index.php

My domain is within the folder of /sites/infusion

And my subdomain is within the folder of /sites/infusion/projects

So why is it trying to access a file it shouldn't be able to reach, shouldn't my domain's root folder be the /sites/infusion instead of the real root folder?
Was This Post Helpful? 0
  • +
  • -

#6 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 08:04 AM

Try the following .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?page=$1 [L,QSA]

Was This Post Helpful? 2
  • +
  • -

#7 56KBs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 17-January 11

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 08:12 AM

Bingo! Thanks a lot!

What's annoying though is that fact I just made some code to change all the header locations from just something into 'index.php?page=something'

Oh well.

This post has been edited by 56KBs: 23 July 2011 - 08:12 AM

Was This Post Helpful? 0
  • +
  • -

#8 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 08:16 AM

You don't need to update your links, of course it's "best practice", however it won't matter from an SEO standpoint if you were to do something like this too:

RewriteRule ^index.php?page=(.*)$ http://yourdomain.com/$1 [L,R=301]


Google will see the permanent redirect and index that, not the index.php?page=XXX url.

Will save you a bit of time, you can clean up your links later.
Was This Post Helpful? 2
  • +
  • -

#9 56KBs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 17-January 11

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 08:52 AM

Now I am very confused.

I am now being told The requested URL /index.php was not found on this server.

Either some of the code I uploaded has an error or something has gone terribly wrong...

Also when I try to get onto just /index I get The requested URL /catalogue/index was not found on this server.

This post has been edited by 56KBs: 23 July 2011 - 08:57 AM

Was This Post Helpful? 0
  • +
  • -

#10 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 09:04 AM

Is this after adding the last line I said? Put it above the RewriteCond lines and see if that helps.

If not, take it out and update your links - Sorry ^_^
Was This Post Helpful? 0
  • +
  • -

#11 56KBs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 17-January 11

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 09:08 AM

No I didn't add in your line of code yet, I will once there is no need for more htaccess fiddling.

It seems I can fix the issue but only for index. If I put nothing in the url then index will load fine, if I put things such as /login or /index then the error appears again.
Was This Post Helpful? 0
  • +
  • -

#12 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 09:11 AM

That's strange, so what's the current contents of your .htaccess now, did you change anything with index.php? What happens if you go to /index.php?page=login manually, does it error? If so, the .htaccess may be freaking out by index.php returning an error after it's rewrote it.

This post has been edited by RudiVisser: 23 July 2011 - 09:12 AM

Was This Post Helpful? 0
  • +
  • -

#13 56KBs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 17-January 11

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 09:23 AM

Current .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?page=$1 [L,QSA]


And visiting the urls with the $_GET's or typing in index.php work perfectly fine, just the other type doesn't.
Was This Post Helpful? 0
  • +
  • -

#14 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 09:29 AM

So what's changed, and how did you fix it for /index?

I mean this was working at one point, right? Or didn't it ever work?
Was This Post Helpful? 0
  • +
  • -

#15 56KBs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 17-January 11

Re: htaccess, nice urls and header location issues

Posted 23 July 2011 - 09:38 AM

It was working as far as I saw, it redirected me to /login as it should and it worked fine.

Oh well, I shall keep just editing my code in the hope it works, if not I can resort to turning off that kind of linking so it's ok.

If only it worked as it does on XAMPP. Maybe it's just the fact it's godaddy
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1