-1

Someone could help me to make a match-rule for my .htaccess ?

I would like that the old urls indexed on search-engines like:

http://www.domain.com/watch.php?id=ANY_ID

redirects automagically to:

http://www.domain.com/watch/ANY_ID

EDIT:

I tried this:

RewriteEngine On
RewriteRule ^watch/([^/]*)$ /watch.php?id=$1 [L]

and this:

Options +FollowSymLinks
RewriteEngine on
RewriteRule watch/(.*) watch.php?id=$1

But is not working for me.

neogeo
  • 41
  • 1
  • 1
  • 9
  • possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Nathan Tuggy May 10 '15 at 00:47
  • @NathanTuggy - I'm not sure why questions are being named as duplicates of that question. I understand why it is being brought up (it is very helpful), but it isn't a duplicate. – Mike Rockétt May 10 '15 at 05:05
  • @MikeRockett: This was more a case of *possible* duplicate than possible *duplicate*, if you will. – Nathan Tuggy May 10 '15 at 05:18
  • @NathanTuggy - Right, understood. – Mike Rockétt May 10 '15 at 05:51

1 Answers1

0

You have only included code that internally maps/rewrites the new URI to the old one. If you want to also redirect the old URI to the new onw, then you can use the following in your /.htaccess file:

RewriteEngine on

# Prevent loops
RewriteCond %{ENV:REDIRECT_STATUS} !200

# Check for old URI and redirect to new URI
RewriteCond %{QUERY_STRING} ^id=([\d]+)$
RewriteRule ^watch.php$ /watch/%1? [R,L]

# Map new URI to file
RewriteRule watch/(.*) /watch.php?id=$1 [L]
Mike Rockétt
  • 8,947
  • 4
  • 45
  • 81