gaza165 Posted January 4, 2009 Share Posted January 4, 2009 can someone give me the regular expression to all A-B, a-b, 0-9 and !"£$%$%^ in my .htaccess file. This is what i have so far, but it doesnt like any symbols such as ! or $ thanks. Options -Indexes RewriteEngine On ErrorDocument 404 /errors/404page.html RewriteRule ^([_\+A-Za-z0-9]+)?$ index.php?c=$1 Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/ Share on other sites More sharing options...
wildteen88 Posted January 4, 2009 Share Posted January 4, 2009 to add symbols such as ! or $ you'll need to escape them, eg \!\$ if you're want to match all characters you can just use (.*) RewriteRule ^(.*)?$ index.php?c=$1 Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729293 Share on other sites More sharing options...
gaza165 Posted January 4, 2009 Author Share Posted January 4, 2009 Options -Indexes RewriteEngine On ErrorDocument 404 /errors/404page.html RewriteRule ^([_\+A-Za-z0-9]+)?$ index.php?c=$1 RewriteRule ^([_\+A-Za-z0-9]+\!)/([_\+A-Za-z0-9]+)?$ index.php?c=$1&title=$2 the second rewrite rule is doing the following. the c=$1 references to the case... so if it was http://www.thedesignmonkeys.co.uk/fb ----- that would be the case 'fb' the next part is the title of the blog so.... http://www.thedesignmonkeys.co.uk/fb/this_is_blog_name!! but for some reason it wont reconise the !! so it will give me a 404 error can someone help me rewrite my rules for them to be able to recosnise !!! or ... thanks Garry Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729296 Share on other sites More sharing options...
wildteen88 Posted January 4, 2009 Share Posted January 4, 2009 You need to place \! within your character set (square brackets) [_\+A-Za-z0-9\!]+ Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729297 Share on other sites More sharing options...
gaza165 Posted January 4, 2009 Author Share Posted January 4, 2009 RewriteRule ^([_\+A-Za-z0-9]+\!)/([_\+A-Za-z0-9\!\,\.]+)?$ index.php?c=$1&title=$2 that still doesnt work.... the title i am using to test is Ready, teddy, go ... into space!! still gives me 404 error Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729299 Share on other sites More sharing options...
wildteen88 Posted January 4, 2009 Share Posted January 4, 2009 URL's cannot contain spaces. You'll need to convert your spaces to dashes - or underscores _ For you're urls I would suggest you try to simplity them a bit, eg ready-teddy-go rather than Ready, teddy, go ... into space!! The aim of tidy urls is to keep them short and simple. I only allow the following chars A-Z (upper or lowercase) 0-9 and only the following symbols -_ making your rewrite rule RewriteRule ^([A-Z0-9_-]+)/([A-Z0-9_-]+)/$ test.php?c=$1&title=$2 [NC,L] NOTE: NC stands for case-insensitive. Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729300 Share on other sites More sharing options...
gaza165 Posted January 4, 2009 Author Share Posted January 4, 2009 i am doing a str replace on any spaces in the urls so Ready, teddy, go ... into space is Ready,_teddy,_go_..._into_space! it just doesnt like the ... or the !... is there nothing i can do to allow these urls?? Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729301 Share on other sites More sharing options...
wildteen88 Posted January 4, 2009 Share Posted January 4, 2009 Sorry I updated my post while you posted, URL's cannot contain spaces. You'll need to convert your spaces to dashes - or underscores _ For you're urls I would suggest you try to simplity them a bit, eg ready-teddy-go rather than Ready, teddy, go ... into space!! The aim of tidy urls is to keep them short and simple. I only allow the following chars A-Z (upper or lowercase) 0-9 and only the following symbols -_ making your rewrite rule RewriteRule ^([A-Z0-9_-]+)/([A-Z0-9_-]+)/$ index.php?c=$1&title=$2 [NC,L] NOTE: NC stands for case-insensitive. Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729302 Share on other sites More sharing options...
gaza165 Posted January 4, 2009 Author Share Posted January 4, 2009 also, in my database, when the blog is pulled back... the £ is not recognised and gives me a ? instead of the £ symbol.... do you know why this is? Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729303 Share on other sites More sharing options...
wildteen88 Posted January 4, 2009 Share Posted January 4, 2009 This is normally caused due to you not telling the web browser which charset to use for displaying fonts. To tell the browser which charset to use you can use the <meta> tag in your HTML eg <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> Your should also ensure you're using a valid DOCTYPE too. Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729305 Share on other sites More sharing options...
gaza165 Posted January 4, 2009 Author Share Posted January 4, 2009 thanks wildteen your the man!! also while im here... can u offer advice on the look of the site and its functionality... would be appreciated Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729308 Share on other sites More sharing options...
wildteen88 Posted January 4, 2009 Share Posted January 4, 2009 If you want to have suggestions for how improve your site post a new topic in the Website Critique forum. Quote Link to comment https://forums.phpfreaks.com/topic/139418-solved-someone-help-with-htaccess/#findComment-729310 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.