I'm trying mod re-write for the first time, and a shared server, using .htaccess.

It seems to work, however the re-directed pages don't load the css, and all the links have a portion of the non-rewriten url in them. For example a link that is an include that simly says <a href="index.htm"> ends up as domain.com/Tag/T/index.htm. Request_URI shows the non-re-writen url, which doesn't seem right considering I didn't think PHP was supposed to see those.

Tag/T/ seems to get appended to the end of the domain for all links.

Here's an example of the trouble code:
RewriteRule Tag/T/(.*).htm$ /tag.php?Tag=$1 [L]

Aside from this, everything seems to work, and my scripts are able to pull the re-writen paramaters and load everything else on the page as normal. When I load the standard .php? page, everything works as usual.

Thanks

    mod_rewrite does nothing to the paths inside the documents you're serving up, thus if you use relative paths such as "index.htm" and whatnot, then of course the browser things you mean /Tag/T/index.htm - how else is it supposed to know?

    What you need to do is add ",R" to your flags on the rewrite rule; this will actually tell the browser to redirect the request to /tag.php?Tag=$1, thus when they load the page, relative links will be based off of the correct directory - the root of your website.

    Alternatively, if you don't want to redirect the browser, you'll have to use absolute paths instead of relative paths.

    EDIT:

    Good2CU wrote:

    Request_URI shows the non-re-writen url, which doesn't seem right considering I didn't think PHP was supposed to see those.

    The rewritten path is done internally with Apache - Apache doesn't alter the request URI (since it wouldn't make sense to - the user didn't request /tag.php to be sent), though it knows to execute the tag.php script given that URI.

      Write a Reply...