Windows vs Linux htaccess problem

Discuss practical ways rearrange URLs using mod_rewrite.

Windows vs Linux htaccess problem

Postby chesare » Mon Nov 27, 2006 2:09 am

Hi,

I'd like to ask for some help with this.
From what I've read, mostly here, I've managed to create my .htaccess to work the way I like it. But the problem is, it only works on my localhost, which is on WinXP. When I try the similar (adapted for specific location) to work on Linux it breaks quite strange.

Here's the WinXP version:

Code: Select all
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdir/

RewriteRule ^(Prefix|prefix)([^\.]+)\.(php|htm)$ http://localhost/subdir/$2 [R=301,L]

RewriteCond %{SCRIPT_FILENAME} -f [OR]
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule .* - [L]

RewriteRule ^([0-9]+)/?$ this.php?one=$1 [QSA,L]
RewriteRule ^([0-9]+)/([0-9]+)/?$ that.php?one=$1&two=$2 [QSA,L]
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/?$ other.php?one=$1&two=$2&three=$3 [QSA,L]

</IfModule>


Basically, what I'm trying is this.
The first "set of rules" (301's) is to redirect old pages to new ones like:
PrefixPagetitle.htm (or .php) -> Pagetitle
The rest is simple (and it works on Linux version, as well): catch some query strings and create urls from them (the variables are dummies, of course).

Long story short - this works on localhost on WinXP. I don't know if this has something to do with OS or perhaps with the fact that I'm trying this on my ~user account (http://website/~user/subdir).

If additional info is needed, I'll provide it. Sorry for possibly poor English, or if something is badly explained.

Thanks in advance.
Greetz.
chesare
 
Posts: 3
Joined: Mon Nov 27, 2006 1:31 am

Postby richardk » Mon Nov 27, 2006 10:23 am

Remove the RewriteBase line or replace it with:
Code: Select all
RewriteBase /~user/subdir/


And you're still redirecting to localhost:
Code: Select all
RewriteRule ^(Prefix|prefix)([^\.]+)\.(php|htm)$ http://website/~user/subdir/$2 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby chesare » Mon Nov 27, 2006 12:29 pm

That was really quick. Thanks.
I removed RewriteBase on Linux and its fine now.

richardk wrote:And you're still redirecting to localhost:
Code: Select all
RewriteRule ^(Prefix|prefix)([^\.]+)\.(php|htm)$ http://website/~user/subdir/$2 [R=301,L]


Oh, I know that... that was/is just an example of "localhost" version that is working.

Thanks once again.
Still, I must ask for some additional help, if that's not a problem.

It's still Win vs Linux problem. On Win, the above mod_rewrite sends my request to actual webpage; for example, if I 'request' an old page http://website/subdir/PrefixPagetitle.htm (or .php),
the above mod_rew redirects me to
http://website/subdir/Pagetitle
and displays the requested webpage (Pagetitle.php).
On the other hand, on Linux,
http://website/subdir/Pagetitle
refers to another subdir.
That is, on Linux, the above url displays as 404 and if I create additional subdir called Pagetitle, it displays its content (empty dir).

Huh, I know this is lousy written, but I hope you know what I mean.
Can I make Linux to display the same thing as Win does?
I mean, to treat the:
http://website/subdir/Pagetitle
as webpage and not as another subdir.

Thanks in advance. I really appreciate your help.
chesare
 
Posts: 3
Joined: Mon Nov 27, 2006 1:31 am

Postby richardk » Mon Nov 27, 2006 2:13 pm

Add
Code: Select all
Options +MultiViews
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby chesare » Mon Nov 27, 2006 3:51 pm

This is perfect.
This is exactly what I was looking for and failed to find on my own.
What can I say... Thanks.
And thanks once again.
chesare
 
Posts: 3
Joined: Mon Nov 27, 2006 1:31 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 6 guests

cron