Page 1 of 1

mod rewrite keeps routing to ROOT

PostPosted: 02. January 2009 15:36
by MikeS999
I wonder if anyone can help please?

I am setting up a 'friendly URL' facility and every time mod rewrite is called it tries to send the browser to the XAMPP root, blocked only by the Username/Password that pops up to protect this level [If already logged in, the stored cookie permits access to the XAMPP front page]

The .htaccess file resident in the appropriate subdirectory "/test/" says;

RewriteEngine on
RewriteRule ^index/([0-9]+)$ /index.php?cat=$1

The function is to take an incoming URL such as "http://www.domain.com/test/index/45" and convert it to "http://www.domain.com/test/index.php?cat=45"

In fact it sends the browser to "http://www.domain.com/xampp/"

Any advice would be very much appreciated. Many thanks for reading this plea!

Re: mod rewrite keeps routing to ROOT

PostPosted: 02. January 2009 15:45
by Wiedmann
Code: Select all
RewriteRule ^index/([0-9]+)$ /index.php?cat=$1

Because of the "/" in "/index.php?cat=$1" mod_rewrite must call a "index.php" in the DocumentRoot (which makes a redirect to the XAMPP dir)

If mod_rewrite should call a "index.php" in the current subdir, just remove the slash:
Code: Select all
RewriteRule ^index/([0-9]+)$ index.php?cat=$1

Re: mod rewrite keeps routing to ROOT

PostPosted: 02. January 2009 15:52
by MikeS999
Wow,

What a very speedy response and thank you so much for your guidance. Needless to say it now works!

Cheers!

MikeS

Re: mod rewrite keeps routing to ROOT

PostPosted: 02. January 2009 17:16
by MikeS999
Sorry to be a nuisance, but....

Firing up "http://www.domain.com/test/index/471" does indeed execute the correct call ["http://www.domain.com/index.php?cat=471"]

For some strange reason everything now appears to be on a virtual sub directory 'index' i.e all links are now preprended with "http://www.domain.com/test/index/"

An example: A link to a help page resident in the root of /test/ normally showing

"www.domain.com/test/help.php"

now shows
"http://www.domain.com/basic_db/index/help.php" - the "/index/" part is added into every link.

This might explain why the root-based CSS file isn't seen.

Any ideas?

Re: mod rewrite keeps routing to ROOT

PostPosted: 03. January 2009 01:13
by Wiedmann
"http://www.domain.com/basic_db/index/help.php" - the "/index/" part is added into every link.

mod_rewrite doesn't change links in the html source code. Your PHP script ('friendly URL' facility) is creating the links, including the additional "/index/" part.

Re: mod rewrite keeps routing to ROOT

PostPosted: 03. January 2009 10:14
by MikeS999
Hi,

Thanks for that. I apologise for possibly posting an inappropriate request in this forum!

I realised in the early hours that I need to code to enable absolute addressing as opposed to relative!

Cheers and many thanks for your wise counsel,

Mike