News:

Click here for Toll-Free Service for your business starting at $2.00 per month

Main Menu

HTACCESS

Started by Osprey, May 02, 2006, 03:31:13 PM

Previous topic - Next topic

Osprey

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,

sven

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...
--
"Everything is futile!"
    -- Marvin of Borg

Osprey

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

Evilsprouts

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 :)

Osprey

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,

neosquared

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
Don't take servers for granted.
Everything is flammable, if you get it hot enough.
Visit my website!  It'll make you cooler!

Osprey

Unfortionately io was already using the second method Neosquared, thank you though.

sixthcrusifix

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.
Visite me website at http://www.sixthcrusifix.com

hypnoticvibe

#8
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.