1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Mod rewrite help

Discussion in 'Apache' started by kdn1, Jan 8, 2020.

  1. #1
    Hi all,

    I have a requirement to change all underscores to dashes, well I have achieved that with these two lines:
    RewriteRule ^([^_]*)_(.*)$ /$1-$2 [R=301,L]
    RewriteRule ^([^_]*)_([^_]*)$ /$1-$2 [L,R=301]

    However now I need to restrict these rules to only apply to a certain page "help.php" (its in the root directory)

    I thought this might do the trick:

    <If "%{REQUEST_FILENAME} ^help/.php$">
    RewriteRule ^([^_]*)_(.*)$ /$1-$2 [R=301,L]
    RewriteRule ^([^_]*)_([^_]*)$ /$1-$2 [L,R=301]
    But that throws a 500 error. can anyone provide some help on how to achieve this?

    kdn1, Jan 8, 2020 IP
  2. Michael_version_2

    Michael_version_2 Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    Hi. What happens if you change <If "%{REQUEST_FILENAME} ^help/.php$"> to <If "%{REQUEST_FILENAME} ^help\.php$"> (note the slash in help.php)? I don't really know <if> rules. I assume they are the same as RewriteCond?
    Michael_version_2, Jan 11, 2020 IP