Forum Moderators: phranque

Message Too Old, No Replies

too stupid to rewrite?

I tried everything

         

apesinspace

9:39 am on Feb 10, 2004 (gmt 0)



hi forum,

I googled 2 hours and read every post in that forum about mod_rewrite, tried all examples, but they didnīt work on my xp-apache-php-thing. so I reduced the commands to the lowest test-thing, found in that forum, too:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^index\.html$ index2.html [R=301,L]

I have a index.html and a index2.html in the directory of that .htaccess, but if I call index.html, nothings redirected :-(
I tried really everything and tried it on the webspace of my provider (linux), too!
what is the problem, or is there a test if mod_rewrite is deactivated? how to activate? Iīm getting crazy *baaaaaaaahhh*

thanks for help

[edited by: jdMorgan at 4:25 pm (utc) on Feb. 10, 2004]
[edit reason] speling [/edit]

jdMorgan

4:24 pm on Feb 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



apesinspace,

Welcome to WebmasterWorld [webmasterworld.com]!

You'll need to make sure you've got mod_rewrite.c compiled-in and loaded, and that you have AllowOverride All, or at a minimum, AllowOverride FileInfo Options set - See the Apache core directives documentation for details.

Also, it may be that you have a settings problem on your own server, and a different problem such as "users not allowed to use mod_rewrite" on your host server.

Jim

apesinspace

10:12 am on Feb 11, 2004 (gmt 0)



thanks, you were right with both things!
now I have another problem. Iīm full of shame, īcause I googled like a madman and tried every code-thing but it didnīt work :-(

I wanna do the often-complained dynamic-php to html-stuff.
my example:

[ibm...]

has to become search-engine-friendly and php has to work in the same way!

so I tried a lot, for example :

RewriteRule ^indexid([^.]+).*$ index.php?id=$1 [T=application/x-httpd-php]

or

RewriteRule ^index([^/]+)/([^/]+)$ dynamic/index.php?id=$1

but nothing happened. rewrite is activated, cause that example worked:
RewriteRule ^index1\.php$ index2.php

are in all that code-lines the condition-position wrong, isnīt it
RewriteRule SEARCHVALUE FINALVALUE
in all the examples found in net it is
RewriteRule FINALEVALUE SEARCHVALUE

can somebody help me, please no links to howtos or faqs, I red them all...

thanks!

Longhaired Genius

11:39 am on Feb 11, 2004 (gmt 0)

10+ Year Member



Remember, you have to decide how your search-engine-friendly urls should look, revise your software to request SEF urls, then rewrite them, with mod_rewrite, to PHP urls.

bird

2:07 pm on Feb 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteRule ^indexid([^.]+).*$ index.php?id=$1 [T=application/x-httpd-php]

What is the [^.] supposed to match?

A single dot will match any character.
A [***] will match any of the enclosed characters ***.
A [^***] will match any character *not* among those enclosed.

This means that [^.] will never match anything.

If your IDs are always numerical, then you probably want something like this:

RewriteRule ^indexid([0-9]+).*$ index.php?id=$1 [T=application/x-httpd-php,L]

Note the L flag that I appended. This will prevent any other rewrite rules to kick in and alter the result again after this one succeeded.

jdMorgan

5:47 pm on Feb 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just a mod_rewrite syntax note here:
Because of the way that group delimiters [] work, [^.] means, "anything but a literal period". Characters enclosed in square brackets do not need to be escaped, except for "]" itself, and perhaps "-" if you wrote [A-Z] (range including uppercase characters A to Z) and really meant [A\-Z] (A,Z, or "-").

Another special case to remember...

Jim