Hi there, does anyone know the correct way of changing this
to allow full stops ?? ex : "."Code:([a-zA-Z0-9_-]+)
Thanks Jamie
Hi there, does anyone know the correct way of changing this
to allow full stops ?? ex : "."Code:([a-zA-Z0-9_-]+)
Thanks Jamie
use \.
Hi, Is this right? as it now just takes me to a error 404 page,
thanksCode:RewriteRule ^(\.[a-zA-Z0-9_-]+)$ profile.php?id=$1 RewriteRule ^(\.[a-zA-Z0-9_-]+)/$ profile.php?id=$1
No, like this:
^([a-zA-Z0-9_-\.]+)$
The brackets create a character class. For example, [a] matches one 'a'; [a-z] matches any character between 'a' and 'z'. The + symbol means match at least once: [a-z]+ means one or more characters between 'a' and 'z'.
The full stop . symbol matches any character. In order to match that particular symbol, you need to escape it with the backslash. The backslash causes the following character to be interpreted literally, ignoring any special meaning.
When you added it outside the character class, you created an expression which matches a full stop followed by one or more characters within those ranges. Moving the full stop inside the character class will give you the effect you want.
Last edited by penagate; Feb 13th, 2012 at 07:22 PM.
Hi thanks for the reply. but thats now giving me a 500 internal server error, any ideas on how i can fix that? thanks
Did you enable RewriteEngine ("RewriteEngine on") prior to your RewriteRules? You could post the full contents of your htaccess file (assuming that's where you're working) for better help - anything that's messed up in there could cause the problem.
Hi this is my htacess file
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
RewriteRule ^([a-zA-Z0-9_-\.]+)$ profile.php?id=$1
RewriteRule ^([a-zA-Z0-9_-\.]+)/$ profile.php?id=$1
p.s, the part in red is causing the internal error,
Thanks
It seems like it's trying to interpret "_-\" as a character set, like "A-Z," except "_-\" makes no sense and is resulting in an error. Try moving the \. to a position where this sequence won't occur:
Code:RewriteRule ^([a-zA-Z0-9\._-]+)$ profile.php?id=$1 RewriteRule ^([a-zA-Z0-9\._-]+)/$ profile.php?id=$1
Good spotting — the hyphen-minus should be escaped as well:
^([a-zA-Z0-9_\-\.]+)$
Hi for some reason, when i do either of the above it seems to ignore the following from my htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
it automatically thinks any thing i goto on my site is a profile.php
any ideas?
thanks!
try adding [L] to the end of the first RewriteRule.
Internal server errorwhen i add [L]
Thanks