-
Feb 13th, 2012, 06:53 PM
#1
Thread Starter
Fanatic Member
([a-zA-Z0-9_-]+) how to allow "."
Hi there, does anyone know the correct way of changing this
to allow full stops ?? ex : "."
Thanks Jamie
-
Feb 13th, 2012, 07:06 PM
#2
Re: ([a-zA-Z0-9_-]+) how to allow "."
-
Feb 13th, 2012, 07:07 PM
#3
Thread Starter
Fanatic Member
Re: ([a-zA-Z0-9_-]+) how to allow "."
Hi, Is this right? as it now just takes me to a error 404 page,
Code:
RewriteRule ^(\.[a-zA-Z0-9_-]+)$ profile.php?id=$1
RewriteRule ^(\.[a-zA-Z0-9_-]+)/$ profile.php?id=$1
thanks
-
Feb 13th, 2012, 08:19 PM
#4
Re: ([a-zA-Z0-9_-]+) how to allow "."
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 08:22 PM.
-
Feb 13th, 2012, 09:06 PM
#5
Thread Starter
Fanatic Member
Re: ([a-zA-Z0-9_-]+) how to allow "."
Hi thanks for the reply. but thats now giving me a 500 internal server error, any ideas on how i can fix that? thanks
-
Feb 14th, 2012, 12:20 AM
#6
Re: ([a-zA-Z0-9_-]+) how to allow "."
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.
-
Feb 14th, 2012, 10:45 AM
#7
Thread Starter
Fanatic Member
Re: ([a-zA-Z0-9_-]+) how to allow "."
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
-
Feb 14th, 2012, 03:23 PM
#8
Thread Starter
Fanatic Member
Re: ([a-zA-Z0-9_-]+) how to allow "."
p.s, the part in red is causing the internal error,
Thanks
-
Feb 14th, 2012, 05:36 PM
#9
Re: ([a-zA-Z0-9_-]+) how to allow "."
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
-
Feb 14th, 2012, 06:06 PM
#10
Re: ([a-zA-Z0-9_-]+) how to allow "."
Good spotting — the hyphen-minus should be escaped as well:
^([a-zA-Z0-9_\-\.]+)$
-
Feb 14th, 2012, 06:14 PM
#11
Thread Starter
Fanatic Member
Re: ([a-zA-Z0-9_-]+) how to allow "."
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!
-
Feb 14th, 2012, 06:19 PM
#12
Re: ([a-zA-Z0-9_-]+) how to allow "."
try adding [L] to the end of the first RewriteRule.
-
Feb 14th, 2012, 06:39 PM
#13
Thread Starter
Fanatic Member
Re: ([a-zA-Z0-9_-]+) how to allow "."
Internal server error when i add [L]
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|