7 Replies - 1152 Views - Last Post: 23 August 2009 - 06:29 AM Rate Topic: -----

#1 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 110
  • View blog
  • Posts: 760
  • Joined: 09-March 08

.htaccess problem

Posted 20 August 2009 - 11:04 AM

my htaccess file is as follows:
RewriteEngine on
RewriteBase / 
RewriteRule ^([A-Za-z0-9-]+)/?([A-Za-z0-9-]+)/?([A-Za-z0-9-]+)/?$ index.php?action=$1&cmd=$2&cmd2=$3 [L]
ErrorDocument 404 /donothing.php


On my free host (http://www.000webhost.com/), they use Virtual directories, so i need the rewriteBase. Problem is, it goes to index/index.php if the URL has a trailing slash.

IE: http://jbrace.net16.net/index/ Is the main page. From there it should mod rewrite to http://jbrace.net16....hp?action=index

That one works, however when It is supposed to go to /login/ (which is /index.php?action=login), it goes to /index/index.php?action=login

I've tried editing things, but unless I want a million subdirectories, i don't wanna add an index folder into an index folder etc...

I had this working fine on another server (which i lost =/), but ow that i've moved, it refuses to work.

Anyone who can help solve this will get a thanks =)

Is This A Good Question/Topic? 0
  • +

Replies To: .htaccess problem

#2 KuroTsuto  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 42
  • View blog
  • Posts: 182
  • Joined: 13-February 09

Re: .htaccess problem

Posted 20 August 2009 - 12:35 PM

I haven't played too much with RewriteBase, but is it possible to have
RewriteBase .
or
RewriteBase ./
?

Or... if you have the ability to make aliases, perhaps you could set RewriteBase to an alias of your base directory? I'm by no means a .htaccess master expert novice, but those are my thoughts... :/

EDIT::
Wait - clarification question:

You said that if the URL had a trailing slash that it got redirected to index/index.php... But when I tested all four of the urls (i.e. /index, /index/, /login, and /login/) they all appeared to rewrite successfully. The only 404 I encountered was when I submitted the login form, which has the form action "index.php?action=login." I modified this in Firebug to submit to /login and it worked fine... If that's the problem, you could just modify your regex so that the URL doesn't rewrite if .php is present, or some such.

But I guess I'm asking... What's the issue here? :blink: (pardon if I seem ignorant ;) )

This post has been edited by KuroTsuto: 20 August 2009 - 12:56 PM

Was This Post Helpful? 0
  • +
  • -

#3 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 110
  • View blog
  • Posts: 760
  • Joined: 09-March 08

Re: .htaccess problem

Posted 21 August 2009 - 06:30 PM

i'm trying to find out why the extra trailing slash makes the redirect go to another folder.

IE: why /login works, but /login/ goes to /index/index.php?action=login
Was This Post Helpful? 0
  • +
  • -

#4 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: .htaccess problem

Posted 21 August 2009 - 06:38 PM

Both /login/ and /login, as previously stated - Work fine.
Was This Post Helpful? 0
  • +
  • -

#5 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 110
  • View blog
  • Posts: 760
  • Joined: 09-March 08

Re: .htaccess problem

Posted 21 August 2009 - 08:59 PM

Go to /login. If you go for a login, it goes to /login/, which is normal. but from /login/, if you send the form, it goes to /login/index.php?action=login when it should stay at /login/

It goes from a mod rewrite recognizing /login/ as a virtual directory, to /login/ as a folder that index.php is in. And if that's not clear enough, then I give up.

This post has been edited by JBrace1990: 21 August 2009 - 10:35 PM

Was This Post Helpful? 0
  • +
  • -

#6 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: .htaccess problem

Posted 22 August 2009 - 04:40 AM

Well you form is pointing there..
<form name="login" action="index.php?action=login" method="post">


Just change that to /login/, you don't have a redirect rule, do you? And if you have, you haven't shown us it.

I just tried that and it works perfectly fine, nothing is changing... Unless you're being seriously unclear.

This post has been edited by MageUK: 22 August 2009 - 04:43 AM

Was This Post Helpful? 0
  • +
  • -

#7 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 110
  • View blog
  • Posts: 760
  • Joined: 09-March 08

Re: .htaccess problem

Posted 22 August 2009 - 10:47 PM

the problem is that I can't use relative URLs like this.

/login/ is a virtual directory. it gets rewritten into the index page.

The problem is, that I have it setup so that the URL for someone's profile would be something like: jbrace.net16.net/users/JBrace1990.

Now, unless I want to go with links like <a href=http://jbrace.net16.net/viewusers>link</a>, I need to find a way to fix it. It's a pain to code everything into a full link when i just want to have the /users/JBrace1990 part
Was This Post Helpful? 0
  • +
  • -

#8 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: .htaccess problem

Posted 23 August 2009 - 06:29 AM

I'm sorry, but I really have absolutely no idea what you're talking about.

EDIT: Ohhh you mean when you're in the /login/ rewrite the next link you view attempts to take you to /login/index.php... You just need to use absolute links beginning with a /. Just like you do when you're within any folder.

This post has been edited by MageUK: 23 August 2009 - 06:30 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1