Buying .htaccess 301 all except two things

Discussion in 'Programming' started by cavendano, Jun 16, 2016.

  1. #1
    I have a site that I need redirected to another URL (301) with the exception of two items.

    My .htaccess file looks like this:
    RewriteEngine on
    Options +FollowSymlinks
    RewriteBase /
    RewriteRule ^view/(.*) redirect.php?view=$1 [R]
    RewriteRule ^rss.xml$ rss.php [L]
    Code (markup):
    I need to keep those rewrite rules active but I need everything else redirected to another url sample.com.

    Example:
    User goes to mysite.com/view/123 they still get to see mysite.com/view/123 they are not redirected. If a user goes to mysite.com/rss.xml they see my feeds not redirected. Everything else can be redirected.
    One more thing the number after view can be anything. So mysite.com/view/123456 still needs to stay with my site and not me redirected.

    Example 2:
    User goes to mysite.com then they go to sample.com
     
    cavendano, Jun 16, 2016 IP
  2. ask2talk

    ask2talk Well-Known Member

    Messages:
    614
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    145
    Digital Goods:
    2
    As Seller:
    100% - 8
    As Buyer:
    57.1% - 2
    #2

    Add the following lines:

    RewriteCond %{HTTP_HOST} !^www.mysite.com$ [NC]
    RewriteRule ^(.*)$ http://www.sample.com/$1 [L,R=301]
    Code (markup):
     
    ask2talk, Jun 29, 2016 IP