FreePgs.com Forum

FreePgs Related => Support Requests => Topic started by: Osprey on May 02, 2006, 03:31:13 PM

Title: HTACCESS
Post by: Osprey on May 02, 2006, 03:31:13 PM
Hey Guys,

I'm working on a new site which requires mod rewrite..

Unfortionately i'm not too familiar with this .. basically i would like to change this url (for example) http://site.com/namehere ----->  http://site.com/page.php?code=1234

If possible, i would also like to be able to change http://site.com/namehere/number to http://site.com/page.php?code=1234number=1234

I tried altering the HTACCESS before, it did "redirect" (I know it doesn't really redirect) as intended.. but it also changed the hyperlinks in the document itself? (Images and CSS files were not loading is they should have..) I would have thought this was possible? Alternatively i could use a special subdomain eg. users.site.com/namehere ?

Any help much appreciated! Never touched the HTACCESS file before at all!

Thanks,
Title: Re: HTACCESS
Post by: sven on May 05, 2006, 04:24:16 AM
Speaking as a fellow newbie to htacess files, I can't really answer your question, however if you hadn't found it before let me recommend this tutorial that helped me grok some of the concepts: http://system.freepgs.com/manual/howto/htaccess.html

Good luck...
Title: Re: HTACCESS
Post by: Osprey on May 06, 2006, 12:11:09 PM
Thanks for the link Sven.

I've not got it setup to a reasonable standard, it is using a real redirect though [R] - Without really redirecting somehow it was fiddeling with the external CSS/PHP/Image files and they weren't loading.

- Osprey
Title: Re: HTACCESS
Post by: Evilsprouts on May 06, 2006, 04:26:15 PM
Does anyone know of a good guide for HTACCESS by any chance please?

Sorry about the topic hijack but no point making a new topic just for this :)
Title: Re: HTACCESS
Post by: Osprey on May 06, 2006, 10:16:03 PM
No worries Evilsprouts, i'd also find it usefull.

I'd really like to know how to avoid it from altering URLS inside the document,
Title: Re: HTACCESS
Post by: neosquared on May 14, 2006, 01:52:18 AM
Quote from: Osprey on May 06, 2006, 12:11:09 PM
Thanks for the link Sven.

I've not got it setup to a reasonable standard, it is using a real redirect though [R] - Without really redirecting somehow it was fiddeling with the external CSS/PHP/Image files and they weren't loading.

- Osprey

I'm going to go out on a limb, and make a shot in the dark.
I'm guessing that you have your external files linked with relative links, like this:
<img src="image.jpg">
<!-- as opposed to: -->
<img src="http://www.example.com/image.jpg">


As a result, when you change the url to example.com/namehere/number, the browser is trying to look inside the /number directory for /image.jpg, which it obviously won't find.  A solution to this is to change your relative links so that they are like this:
<a href="/namehere/image.jpg">
That way the links work regardless of what directory the browser thinks that it's in, and you get to keep your relative link goodness.

As I said, I could be wrong, but I've had the above problem before, so I'm hoping I'm not the only one.  :P
Title: Re: HTACCESS
Post by: Osprey on May 19, 2006, 09:39:55 PM
Unfortionately io was already using the second method Neosquared, thank you though.
Title: Re: HTACCESS
Post by: sixthcrusifix on May 23, 2006, 03:18:49 AM
Quote from: Osprey on May 19, 2006, 09:39:55 PM
Unfortionately io was already using the second method Neosquared, thank you though.
did you put a period in front like this:

<img src='./blah/blah.png'>

? I think you put a period for each folder farther away form the root.
Title: Re: HTACCESS
Post by: hypnoticvibe on May 23, 2006, 07:01:32 AM
Quote from: sixthcrusifix on May 23, 2006, 03:18:49 AM
Quote from: Osprey on May 19, 2006, 09:39:55 PM
Unfortionately io was already using the second method Neosquared, thank you though.
did you put a period in front like this:

<img src='./blah/blah.png'>

? I think you put a period for each folder farther away form the root.
The UNIX filesystem structure (which is what the server is) is set up like this:
. means the current directory
.. means one directory prior
../.. means 2 directories prior (this pattern continues)
~ means all the way back to the root directory

Even if the server was in the Windows NT family, the . and .. would still apply

I'm not exactly sure what your problem is but if the page that it redirects to works when you go straight to it but fails only through using the .htaccess file...
Why don't you use the META redirect instead?
Place this in the head of your HTML:
<meta http-equiv="Refresh" content="0;url=http://www.domainhere.com/subdirectory/page.htm">

*edit*
I should probably warn you that if you're going to get into UNIX, ~ technically means the home directory but in this case (webdesign) it will take you back to the domain name's root directory.