Forum Moderators: phranque

Message Too Old, No Replies

mode rewrite

What did I wrong now? :-S

         

caspita

7:31 pm on May 6, 2004 (gmt 0)

10+ Year Member



I think is about 3th time I come with the same kind of issue but, belive me, I had been trying hard, but this is not my field :-(

Trying to setup mode rewrite to have a sub-domain going URI friendly, but also tryin to go with no specific extensions for my pages.

Basically I'm trying to redirect [subdomain.mydomain.com...] to [subdomain.mydomain...]

I have the following .htaccess file into the root folder/directory for my sub-domain:

RewriteEngine on
RewriteRule ^(.*) /index.php?html_page=$1 [L]

for the secon line I have tryied many combinations like ^(.*) , (.*) , ([^/]*), ^(.*)$ and more that I'm not remember now.

The funny thing here is that if I try different URIs I get different results ie.:

- If I use [subdomain.mydomain.com...] , it redirects to index.php, but then in the html_page parameter I get again the script name 'index.php' intead of the 'abc/def'

- If I use [subdomain.mydomain.com...] (note the use of .something as any extension which is not .html) I get 500 Internal Server Error in the browser but nothing in the error log.

- and If I use [subdomain.mydomain.com...] then it works fine and I get the redirection and the correct value in the html_page parameter which is 'abc/def' (note that i'm not getting the .html) but then I don't want to use .html extension for my pages, I don't want ot have extensions at all

Could somebody give me a hand here?

Thank you very much in advance.

Carlos.

caspita

8:46 pm on May 6, 2004 (gmt 0)

10+ Year Member



Some more info,

I forgot to say that tha basic example is working:

RewriteEngine On
RewriteRule ^(.*).html /index.php?html_page=$1 [L]

it redirects ie:

[subdom.mydom.com...] to [subdom.mydom.com...]

so, if I put my links in the pages as .html it will work, but I'd like to go with no extension at all. But just taking out the .html from the rule make the redirect not working at all :-(

This does not work

RewriteEngine On
RewriteRule ^(.*) /index.php?html_page=$1 [L]

to redirect :

[subdom.mydom.com...] to [subdom.mydom.com...]

Carlos.

jdMorgan

8:53 pm on May 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Carlos,

It sounds like you have some interactions going on between rewriterules or some other Apache modules, such as mod_dir, mod_mime_magic, and maybe others.

If you are getting a 500-Server Error but no entry in your error log, then that's the first thing to investigate -- You'll need those logs to help fix the problems.

From what you've said, the problem sounds like it's related to content negotiation interfering with the URL before mod_rewrite gets the request... That's the only reason I can think of that ".html" would be stripped out of the last test case in your first post. Hopefully, others may spot something that leads to further recommendations.

Jim

gergoe

8:58 pm on May 6, 2004 (gmt 0)

10+ Year Member


the best you can do yourself is to enable the logging of the rewriting engine, so you can see in the logs what's going on.
about the problem; it sounds like something related to the paths on the server, so it could be that the use of he RewriteBase will solve your problem, but i'm not sure about this. (since you use .htaccess files, the rewriting is done on directory level, not on server level which would be better for your).
additional option is to use the request_uri variable for the rewriting, not the uri passed to the RewriteRule, like this:
RewriteRule .+ /index.php?html_page=%{REQUEST_URI} [L]

caspita

9:43 pm on May 6, 2004 (gmt 0)

10+ Year Member



Thanks jdMorgan and gergoe,

the reason because I'm using .htaccess is because I'm not the host owner :-( so I have no access to the main config file for the apache, I'll try to find out more help about this with my hosting support and see if they can check something from the info you gave me.

Thanks a lot, I'll keep you posted.

gergoe, I tried your way but I'm getting 500 error also.

I'll let you know guys when I find out something.

Thanks again,

Carlos.