Forum Moderators: phranque
I have checked a couple of things already; phpinfo() says mod_rewrite is loaded and a test I found on another website worked (RewriteRule /yahoo.me [yahoo.com)....] Another similar test also worked (RewriteRule /index [yahoo.com)....]
Yet my own rules will not work (which worked on the server run off my hard drive). Does it make any difference that my server is Windows, and the webserver is Linux?
Here are couple of my rules;
RewriteEngine on
RewriteRule ^index/?$ index.php [L]
RewriteRule ^index/sess/([^/\.]+)/?$ index.php?sess=$1 [L]
RewriteRule ^index/([^/\.]+)/?$ index.php?q=$1 [L]
RewriteRule ^index/([^/\.]+)/sess/([^/\.]+)/?$ index.php?q=$1&sess=$2 [L]
All of my rules are of the same structure, just with different values. If there something missing? Have I done something incorrectly? Any help and ideas are greatly appreciated.
Thanks
Two most likely causes:
1) Code in .htaccess may need to be preceded by
Options +FollowSymLinks
RewriteRule [b]^/in[/b]dex/?$ index.php [L]
However, I have got somewhere.
I am operating in a sub-domain (although I tried it on a www. too and the same happened). Anyway, I visit {url}/index/join which should redirect to index.php?q=join. Now after some testing, I managed to get it to work when I left off the index/ on the rewriterule. ie:
RewriteRule join/?$ index.php?q=join [L]
Then it works fine. It seems to be skipping the first part. I can't do this though, as another rule uses that first part with a variable in. ie:
RewriteRule ([^/\.]+)/?$ artlog.php?title=$1 [L]
How do I stop it skipping the first part? I've been looking at RewriteBase, but I have no idea what I would need to do with it exactly to get it to read the first part as well.
[edited by: Fourjays at 12:15 pm (utc) on Aug. 23, 2006]
At what directory level? The .htaccess file is a "per-directory" configuration file. Therefore, if this code is located *in* /index/, then that part of the patch will be stripped off (for security reasons), and RewriteRule will never see it. You will need to move your code to the Web root directory (above /index/) in order for it to be able to test for "/index".
At any rate, this sounds like a problem related to the location of the code, rather than any basic functionality problem, and that's good news.
Jim
Well I'm operating on a sub-domain (artlog.example.net), so all the files (index.php, download.php, etc) are directly in that folder (public_html/artlog), including the .htaccess. I've tried to illustrate the structure below (tried being the key word). There isn't a index folder, but some other folders like /includes, /templates and /images. None of which have an .htaccess in them.
public_html
- artlog
- - .htaccess
- - index.php
- - download.php
- - etc...
Thanks for your continued help.
[edited by: jdMorgan at 2:15 pm (utc) on Aug. 23, 2006]
[edit reason]
[1][edit reason] Examplified [/edit] [/edit][/1]
A path-part can be a file or a directory, but not bothat the same time.
I am thinking maybe you've got an interaction here between a DirectoryIndex directive and your rules... Do you have a DirectoryIndex directive in .htaccess or httpd.conf? If so, what does it say?
Jim
I don't have a DirectoryIndex directive in .htaccess. All there is in my .htaccess is "Rewrite Engine on" followed by the rules. I'm not sure about httpd.conf. I can't access it on the webserver (that I can see), as I'm on a shared hosting account (I'll ask my host when I next talk to him).
Found this (http://www.webmasterworld.com/forum92/2282.htm) after another hour of searching on Google. I read through it, and it seemed similar. So I tried what Garfield did (blah/join to index.php?q=join) and it worked fine. So I then added the option you (jdMorgan) suggested in the thread, of adding "Options -MultiViews" to the top, and it all seems to be working fine. :D
Such a short line fixes such a strange problem...
Thanks for all your help jdMorgan, and the advice posted in the other thread. :)