Forum Moderators: phranque
First i would like to tell You that I am not well in English, but i will try. And of course i want to say hello because this is my first post here.
I've got a big problem with my .htaccess file, i'am trying to solve my problem for about two weeks and nothing i can do.
I take my web in the new server where is working Apache 2.2, my .htaccess stop working.
I' ve got URL's like this:
http://www.example.net/index.php?id=kac
http://www.example.net/index.php?id=kac_swome
http://www.example.net/wina/index.php?id=kac_swome
but i want to have like this:
http://www.example.net/kac
http://www.example.net/kac,swome
http://www.example.net/wina/kac,swome
etc.
I've tried to solve with this RewriteRule:
RewriteRule ^(.*)$ index.php?id=$1 [L]
but it isn't working.
I have read on this forum about this:
RewriteRule ^([^./]+)\.html$ /index.php?id=$1 [L]
and it is working on my server, but i don't want ".html" in the end. So i tried to remove this like that:
RewriteRule ^([^./]+)\$ /index.php?id=$1 [L]
and nothing works corectly.
Look at my page:
http://www.example.net/index.php?id=kac
works fine, but:
http://www.example.net/kac
is not ;/
My whole .htaccess file is:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?id=$1 [L]
Please, help me. I dont't have ane ideas to do this myself and my site doesn't work since two weeks ;/
I hope that someone can understand m English ;)
I was looking in that forum an answer but i didn't find, if an identyical problem was somewhwre solved i would be greatful for link.
Bye
[edited by: jatar_k at 1:41 pm (utc) on May 10, 2008]
[edit reason] please use example.net [/edit]
If your new server is Apache 2.2, and your old server was Apache 1.x, then it is possible that you need to add
AcceptPathInfo Off
You may also need to add
Options +FollowSymLinks -MultiViews
Try adding these two directives. If this does not help, please try to give us more information on *how* your rules do not work. Do you get an error message in the browser? Do you get any error information in the server error log?
Jim
And You have right, it works perfectly in URL like (with one word):
http://www.example.net/kac
but when I want to click something like that (two or more words) (#1):
http://www.example.net/kac,regionalny
i get error:
Warning: include(kac,regionalny.php) [function.include]: failed to open stream: No such file or directory in /home/wina/domains/example.net/public_html/index.php on line 113
Warning: include() [function.include]: Failed opening 'kac,regionalny.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/wina/domains/example.net/public_html/index.php on line 113
----------------------------------------------
My .htaccess file:
AcceptPathInfo Off
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?id=$1 [L]
#1
RewriteRule ^(.*),(.*)$ index.php?id=$1_$2 [L]
#2
RewriteRule ^spis,win/(.*)$ index.php?id=spis_win/$1 [L]
#3
RewriteRule ^wino/(.*)$ wino/index.php?id=$1 [L]
-------------------------------------------------
I've got also another problems with mod_rewrite.
#2
http://example.net/index.php?id=spis_wina/a
works, but that:
http://example.net/spis,win/a
doesn't, i've got the same error.
-------------------------------------------------
#3
http://example.net/wino/index.php?id=ciociosan
works, but that:
http://example.net/wino/ciociosan
doesn't.
I have tried to change myself your RewriteRule but I always get the same errors. The older Apach was easier ;)
Sorry, that I have w lot of questions but when i write to server admins they told me "get lost" and do it yourself ;/
One more thanks.
An alternative would be to encode the comma as %2C
Example: <a href="http://www.example.net/kac%2Cswome">
See RFC 2396 - Uniform Resource Identifiers (URI): Generic Syntax [faqs.org] for more information.
Jim
RewriteRule ^(.*)-(.*)$ index.php?id=$1_$2 [L]
i got an error:
Internal Server Error
on my entire page.
I don't know if I understand You. In HTML code instead of comma I should give "%2C" ? What about in htaccess code, can I use comma or %2C ?
I tried in every possible way with that and it isn't still working. ;/
http://www.example.net/kac,regionalny
either
http://www.example.net/kac-regionalny
Nothing.
I would prefer comma "," character beacuse i linked my subpages for a long time and it would be big waste for me.
Could You tell how about point #3 form my previous post ?
Why it's not working ?
Thanks a lot that you find a time to response me. I really apriciate.
You must include:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Or you may wish to add one instance of:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [S=9]
Put your rules in order, from most-specific to least-specific. Use very-specific patterns to avoid unintended pattern matches.
I would suggest:
AcceptPathInfo Off
Options +FollowSymLinks -MultiViews
RewriteEngine on
#
# Skip next 4 rules if URL resolves to existing file or directory
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [S=4]
#
RewriteRule ^spis,win/([^/,]+)$ index.php?id=spis_win/$1 [L]
RewriteRule ^wino/([^/,]+)$ wino/index.php?id=$1 [L]
RewriteRule ^([^/,]+),([^/,]+)$ index.php?id=$1_$2 [L]
RewriteRule ^(.*)$ index.php?id=$1 [L]
Also, it is far easier to get one rule working, then add one more, get that working, then add one more, rather than trying to debug a huge pile of rules all at one time.
Jim