.htaccess URL re-write

MistaMerlin

Inactive User
Joined
Jan 20, 2006
Messages
86
Reaction score
0
I know this isn't a web design forum but I thought id ask anyway...

I can't seem to get the .htaccess to rewrite the URL on my website, I have checked with my host and Apache is enabled for this, but it doesnt seem to work. Anyone got any ideas?

This is the code im using.....

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(/community/component/option,com) [NC,OR]
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteRule ^(content/|component/) index.php
 
I'm no expert on this, and it's a while since I used regexp's, but here goes.

The first RewriteCond checks there's no exising file. Should work fine.
Same for the second which checks for directories.
The third line will ONLY match "/community/component/option,com". Is that really what you want?
Fourth line will match a REQUEST_URI that is "/.htm", ".php",".html" or everything up to a dot preceeded by a "/".
I think you've probably got your patterns wrong. What are you trying to match? The third line is especially confusing.

As for the rewrite rule, that will convert "content/" or "component/" into index.php (you might need a "/" at the beginning of the pattern, I think it depends on how Apache is set up).

It's not working because you're not matching what you want. Even if you do match one of the RewriteCond's, the url CANNOT be affected by your RewriteRule.

Let me know what you want to achieve and I'll see if I can come up with anything.
 
Thanks for your reply,

It's a rewrite for those pesky php query strings, to make them more search engine friendly. The idea of the third line is that it takes each aspect of the query and reduces it to a directory structure. Basically im looking to turn something like this...

h**p://www.liquefysoundz.co.uk/community/index.php?option=com_fireboard&Itemid=3

into...

h**p://www.liquefysoundz.co.uk/community/index/option/com_fireboard/

I know the original URL in this example is pretty search engine friendly anyway as the string isn't to long, but I have a few URL's that go on for miles :)
 
To be honest, I don't see a way to do this for general URLs using just RewriteCond and RewriteRule, especially if you've got lots (and differing numbers) of php arguments. I think a better way to do it would be to use the RewriteMap directive. This allows you to specify an arbitrary script to do the processing. This could include loops, conditionals, arbitrary arguments and the like. Have a look a the bottom of this page for a quick example.

Sorry I couldn't help more.

Good luck.
 
Thats what the link is in my post. lol.

edit: Or just about, they all link to each other.
 
Last edited:
Thats great help guys, thank you very much. I'll tell you how I get on.

h**p://www.liquefysoundz.co.uk/community/ is the site if you where interested....
 
Back
Top