Click to See Complete Forum and Search --> : .htaccess


adamou
07-05-2010, 12:27 AM
Hey there,

I am writing a rewrite condition for a website of mine; anyhow


DirectoryIndex Index.php

Order deny,allow

RewriteEngine on

#SEO
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^/]+)-([^/]+)-([^/]+) Index.php?id=$1&make=$2&model=$3 [L]


Is there a faster implementation of that? Essentially my URL will look like

http://mywebsite.com/v/123-somename-lastname

I will probably replace - with some other deliminator if the need be, but however; any suggestions on writing my condition much more efficient and faster?

Thank you very much.

adamou
07-07-2010, 09:19 PM
I couldn't edit the original post, but I rewrote the regex as

RewriteRule ([^_]+) Index.php?id=$1&make=$2&model=$3 [L]

which works like a charm and splits the url by _

Jarrod1937
07-07-2010, 10:34 PM
On a side note, you should not remove the extension of the page. You can obscure the page type, like if the page is .asp/.php...etc and it serves html you can use a .html extension. However google and other search engines may have a preference to not removing extensions so that they don't have to guess as to what the content type may be (i've seen it mentioned here and there, and once by googles video blogs).

adamou
07-07-2010, 11:57 PM
Thats a very good idea thank you!

How would I re-write the regular expression however? I want it to be able to split _ from the URL

([^_]+).html doesn't work it only grabs

123_123_123.html

Is there any idea?

I could do ([^_]+)_([^_]+)_([^_]+).html, but I Think that is slow isn't it?

Anyhow I added .html regardless, the third parameter isn't useful yet anyhow.
::edit::

Ok I wrote it as ([^_]+)[^\.html], that seems mildly appropriate for now ... any improvements however?