Hi, I've been working on the following mod rewrite rules: RewriteEngine on Options +FollowSymlinks RewriteCond $1 !index\.php$ RewriteRule ^([^/]+)/([^/]+)/?$ index.php?page=$1&subpage=$2 [L] # RewriteCond $1 !index\.php$ RewriteRule ^([^/]+)/?$ index.php?page=$1 [L] Code (markup): what it's supposed to be doing is rewrite urls, like: http://domain.com/article1 to http://domain.com/index.php?page=article1 and http://domain.com/article1/subarticle to http://domain.com/index.php?page=article1&subpage=subarticle This works (sort of). If I load a page by clicking on a link (for example: http://domain.com/article1) the correct page loads (i.e. http://domain.com/index.php?page=article1) BUT the URL that appears in the address bar of the browser reads: http://domain.com/article1/?page=article1 I have triple checked and there is nothing in my php script that would add this, so I'm assuming that the rewritten url gets passed through the mod rewrite rules again. If anyone has a solution I would be really greatful as I've been stewing over this problem for quite some time now. Thanks. Stefan
try this buddy Options +FollowSymLinks RewriteEngine on RewriteRule index/(.*)/(.*)/(.*)/(.*)/$ /index.php?$1=$2&$3=$4 Code (markup): it will make it like this yourdomaindomain.com/index/page/article1/subpage/subarticle/
<IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^([A-Za-z0-9-]+)/?$ /index.php?page=$1 [L] RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /index.php?page=$1&subpage=$2 [L] </IfModule> Code (markup): I hope this works I just wrote it up quick.
Hi, thank you for all of your replies. I'm afraid that none of the above suggestions would work, as the parameters are also real directory names. Apparently there is a clash between mod_rewrite and mod_dir, which results in the funny url "?page=article1" being added at the end of the URL. Modifying the directory names is not really an option, so if anyone has an idea on how to "untangle" mod_rewrite and mod_dir.... Nintendo: I'm actually using absolute URLs in my code, e.g. http:// localhost/textcms/phitetest (the base URL) and http:// localhost/textcms/phitetest/article1/subarticle1 (space between http:// and the rest of the url because I don't have access to live links here yet) Thanks. Stefan
If you plan to ever have any visitors, http:// localhost/ won't work at all. http://www.domain.com is what you want. View the HTML code of the page and see what you get in the link.
Thanks Nintendo, but that's not the issue here. I'm using a local development server, which is why it is localhost. The problem is that no mod rewrite rule seems to work because of the conflict between mod_rewrite and mod_dir I described above. Thanks. Stefan