-1

I am trying to write a rule that will ignore a particular link in my .htaccess

RewriteRule ^([a-zA-Z0-9-_",'w\s@]+)$ profile?u=$1
RewriteRule ^([a-zA-Z0-9-_",'w\s@]+)/$ profile?u=$1

the code above will redirect any link like http://me.com/you

to http://me.com/profile?u=you

but i want it to ignore the word contact so that when the user types me.com/contact

the user goes to the contact page instead of going to me.com/profile?u=contact

thanks, your help will really be appreciated

Ruslan Osipov
  • 5,655
  • 4
  • 29
  • 44
  • This belongs to *regex* and not *php*. Negative lookahead might help http://stackoverflow.com/questions/1749437/regular-expression-negative-lookahead . – mlt Jun 14 '12 at 01:10
  • I never new there was any thing like category here – me akindele Jun 14 '12 at 01:17

1 Answers1

0

Add this right before the rule to exclude the word:

RewriteCond ^((?!contact).+)$

Really, you can look it up in a reference.

Ruslan Osipov
  • 5,655
  • 4
  • 29
  • 44
  • [Thu Jun 14 02:26:52 2012] [alert] [client ::1] C:/xampp/htdocs/.htaccess: RewriteCond: bad argument line '!^/webtop$' [Thu Jun 14 02:26:52 2012] [alert] [client ::1] C:/xampp/htdocs/.htaccess: RewriteCond: bad argument line '!^/webtop$' – me akindele Jun 14 '12 at 01:27
  • @meakindele what does the log sat this time? – Ruslan Osipov Jun 14 '12 at 01:57
  • C:/xampp/htdocs/.htaccess: Invalid command '^((?!contact).+)$', perhaps misspelled or defined by a module not included in the server configuration – me akindele Jun 14 '12 at 02:01
  • do you use apache mod_rewrite? Sure you add `RewriteCond` and not a `RewriteRule`? – Ruslan Osipov Jun 14 '12 at 02:05
  • i made a mistake that generated the last error, i have corrected it and now its back to the first error – me akindele Jun 14 '12 at 02:53
  • 1
    an ideal came to my mind ignoring any folder or file name so i use this RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Thanks – me akindele Jun 15 '12 at 03:18