Forum Moderators: phranque

Message Too Old, No Replies

htacces-Rewrite doesn't work

         

Tompa

9:35 am on Jun 17, 2010 (gmt 0)

10+ Year Member



Hi,

i want to rewrite my URLs:

Old: http://example.de/tags/buch.html
New: http://example.de/tags.php?tag=buch

My htaccess right now:

AddHandler php53-cgi .php
ErrorDocument 404 /404.php
RewriteEngine on
RewriteRule ^tags/(.*).html$ tags.php?tag=$1



Has anyone any idea why it doesn't work?

Thanks!

[edited by: jdMorgan at 2:43 pm (utc) on Jun 17, 2010]
[edit reason] No URLs, please. Use example.com only. [/edit]

jdMorgan

2:48 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try a simple rule first:

RewriteRule ^test\.html$ http://www.google.de/ [R=301,L]

Request "/test.html" from your server, and you should end up at google.

If that does not work, then be aware that the directive

Options +FollowSymLinks

is required ahead of "RewriteEngine on" on many servers, and further, that using

Options +FollowSymLinks -Indexes -MultiViews

often avoids several other problems as well.

Jim

[edited by: jdMorgan at 12:40 am (utc) on Jun 18, 2010]

Tompa

3:25 pm on Jun 17, 2010 (gmt 0)

10+ Year Member



Thank you for your reply.

I tried the Rewrite to google. It worked. No Problem.

After that I deleted it again. Ok? Or do you want to see it?


Even with Options +FollowSymLinks at the top of the htaccess, my rewrite still doesn't work.

Any other idea?
Is the syntax of my htaccess right?

Thanks!

jdMorgan

5:18 pm on Jun 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From the description of what you want to do, this would be better:

RewriteRule ^tags/([^.]+)\.html$ /tags.php?tag=$1 [L]

But those changes won't 'fix' the likely proble, just make the code more efficient.

What do you see in your server error log file?

Is this code in example.de/.htaccess or in another location?

Is the script at example.de/tags.php or in a different location?

Jim

Tompa

5:32 pm on Jun 17, 2010 (gmt 0)

10+ Year Member



Hi Jim,

I added your code to the htaccess. You were right, it didn't fix my problem.


The errorlogfile doesn't say anything, because when you open http://example.de/tags/buch.html you get a code 200.

http://example.de/tags/buch.html redirects to http://example.de/tags.php but doesn't get the "?tag=buch"

It is like that:

example.de/.htaccess
example.de/tags.php


There is now folder called "tags".




When I add a " var_dump($_GET); " to the tags.php I get:

tags/buch.html:
array(0) { }


tags.php?tag=buch:
array(1) { ["tag"]=> string(4) "buch" }

jdMorgan

12:42 am on Jun 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, the code is correct. So, assuming that the code is located as I asked about above, some other 'agent' --a rewriterule or some other server module directive-- must be interfering.

Jim

Tompa

12:51 pm on Jun 18, 2010 (gmt 0)

10+ Year Member



What do you means exactly?

How can I see if there is some other agent?

jdMorgan

2:39 pm on Jun 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Review your server config files and any other .htaccess files in the directory-paths to the original or new filepath.

I used the word "agent" to mean "any configuration directive or script" generically -- I can't see your server, and it could be one or both. All I can say is that it is 'code' that can take some action to interfere with your desired result. Mod_alias, mod_dir, mod_negotiation, mod_proxy, mod_speling, mod_rewrite, and any other 'URL-rewrite-capable' module directives or scripts which might be invoked before your .htaccess code can execute.

Jim