Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule Problem

rewriterule not working

         

aliasbdi

3:34 am on Nov 18, 2007 (gmt 0)

10+ Year Member



I am a newbie to this sort of thing ... but I have successfully made several rewriterules in my time. However, this one is really driving me nuts.

I have a directory on my site named "eControl" and inside of this directory is the file named "index.php" which is what all url's should land on.

For example, anyone who goes to "http://www.domain.com/eControl/documents/list/new/" would be redirected to "http://www.domain.com/eControl/index.php?1=documents&2=list&3=new"

Here is my code:

RewriteEngine on

RewriteRule ^eControl/?$index.php[QSA,L]
RewriteRule ^eControl/([-A-Za-z0-9]+)/?$ index.php?section=$1 [QSA,L]
RewriteRule ^eControl/([-A-Za-z0-9]+)/([-A-Za-z0-9]+)/?$ index.php?section=$1&action=$2 [QSA,L]
RewriteRule ^eControl/([-A-Za-z0-9]+)/([-A-Za-z0-9]+)/([-A-Za-z0-9]+)/?$ index.php?section=$1&action=$2&actionID=$3 [QSA,L]

I put the .htaccess file in the root "http://www.domain.com/" and the page I want to serve is "http://www.domain.com/index.php".

Thanks for the help.

jdMorgan

3:11 pm on Nov 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first rule is invalid, since it is missing spaces in two places.

Other than that, what exactly do you mean by "doesn't work"?

Do you get an error? Anything in your server error log? What URL-paths did you test with?

Jim

aliasbdi

7:07 pm on Nov 18, 2007 (gmt 0)

10+ Year Member



Why is the first rule invalid?

It doesn't work because no matter the url's I try, they should always go back to the "/eControl/index.php" page. So when I try these it should work:

/eControl/document/list/new
/eControl/document/list/
/eControl/document/

Instead, I go to a 'page not found' error. I don't think that I have access to the log files.

http://example.com/eControl/ (works fine)
http://example.com/eControl/document/list/ (does not work)

However, you can see a different error (a 404) by going here:

http://example.com/eControl/document/list/page.php

So it seems that this rewriterule is not even doing anything.

THanks.

[edited by: jdMorgan at 9:04 pm (utc) on Nov. 18, 2007]
[edit reason] example.com [/edit]

Dilly

7:14 pm on Nov 18, 2007 (gmt 0)

10+ Year Member



Jim is saying that you are missing spaces in this line in 2 places

RewriteRule ^eControl/?$index.php[QSA,L]

Should be

RewriteRule ^eControl/?$ index.php [QSA,L]

[edited by: Dilly at 7:14 pm (utc) on Nov. 18, 2007]

aliasbdi

2:13 am on Nov 19, 2007 (gmt 0)

10+ Year Member



I understand. That must have happened when I posted. It is not in the .htaccess file. But is my code and URL paths correct? I mean, is my understanding right?

jdMorgan

2:28 am on Nov 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Where is your .htaccess code located -- In root, or in a subdirectory?

Do you have any rules in that file that work?

Have you tried something simple, like
RewriteRule ^foo\.html$ [google.com...] [R=302,L]

Does anything show up in your error logs pertaining to these requests?

Jim

aliasbdi

2:11 pm on Nov 19, 2007 (gmt 0)

10+ Year Member



Aha ... figured it out. The server settings were set incorrectly. They are being resolved now and so it should start working. Thanks for the help.

phranque

2:24 pm on Nov 19, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], aliasbdi!