Forum Moderators: phranque
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.
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.
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
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.