[^] Need Help With Regex (for .htaccess)

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

[^] Need Help With Regex (for .htaccess)

Amezis
Well, I ran into a problem. I tried to make a code that matched everything, except strings containing the word "php", "gif", "jpg" etc. I tried doing something like this, but it didn't work:

CODE
([^\b(php|gif|jpg)\b]+)$


But that works just like if I would do this:
CODE
([^phgifj]+)$


That code is a part of a larger code that only works partially:

CODE
RewriteEngine on

RewriteRule   ([^\b(php|gif|jpg)\b]+)$    item.php?n=$1


Some strings, such as asd works, but fgh doesn't work.

Any help for either of these problems would be greatly appreciated! As you might see, I'm no master with regex... well, not yet wink.gif

 

 

 


Reply

hts
http://www.javascriptkit.com/howto/htaccess10.shtml

see here..I think you will find what you are looking for..of course, that code must be adapted to suit your needs..but it`s easy to understand smile.gif

Reply

Amezis
It didn't help me much, but I finally found out how I could fix everything. Here's the code I'm using:

CODE
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule   (.+)$    item.php?n=$1


smile.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. regex htaccess lower case - 270.50 hr back. (1)
Similar Topics

Keywords : regex htaccess

  1. .htaccess-style Login System And Php - (13)
  2. .htaccess Redirect Question - redirect ALL traffic to another domain (6)
    I want to redirect all my traffic from one site to another domain name. Is this possible, and if so,
    would I do something like this: .htaccess code: CODE redirect 302 /
    http://www.mynewdomain.com Thanks!...
  3. Cleaning User Input With Regex - (1)
    As anyone who works with user input knows, not everyone who submits information makes it look
    proper. One one of my web forms, I parse all the needed fields that I wish to be title cased; their
    name, address, city, etc. I use this to perform this action, which works nicely: PHP Code: CODE
    $string = ucwords(strtolower($string)); This fixes the input if
    the user types in all caps or all lowercase. There is a problem I have been noticing about those who
    enter a generation after their name, such as "Bill Warner III". The above functio...
  4. .htaccess Charset Problem... - (2)
    I have a problem with the charset in my php page... firstly the whole site included .html and .php
    didn't automaticly get the right charset i put in the meta content so I added a .htaccess file
    CODE AddDefaultCharset Big5 then it works fine with the .html file extension... but not my
    php file... so i added another line in .htaccess file CODE AddCharset Big5 .php but still
    not working... there is something i wondering... coz my link to the php file is "foo.php?A=B" would
    that be the problem that the .htaccess file dun see it as a normal .php? Pl...



Looking for regex, htaccess

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for regex, htaccess

*MORE FROM TRAP17.COM*
advertisement



[^] Need Help With Regex (for .htaccess)



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE